Search Unity

Search tool cannot use some properties

Discussion in 'Editor Workflows' started by Trisibo, Nov 22, 2022.

  1. Trisibo

    Trisibo

    Joined:
    Nov 1, 2010
    Posts:
    245
    I can't for the life of me make the search tool find assets with some properties (Unity 2021.3.13f1). For example, I have a ScriptableObject class "CaseInfo", with these fields (among others):

    Code (CSharp):
    1. [SerializeField] string backendId;
    2. [SerializeField] string id;
    3. [SerializeField] bool alwaysAvailableInTestBuilds;
    If, for example, I search for "t:caseinfo id=1aec1a3c486c411397f4e1b6a0eb5c52", I get the error "Unknown filter "id"" in the search window status bar. Same for something like "t:caseinfo backendId=asdf". But if I search for "t:caseinfo alwaysAvailableInTestBuilds=true" it works...

    I have built and rebuilt and forced build and saved and restarted and built again the index from the index manager window, but it just doesn't work. In the keywords list I can see a pair of "backendid:xxxx" entries, but they are for other classes, not for "CaseInfo", but it doesn't even seem to matter since I also cannot search for that property on those classes. How on earth is this supposed to work?
     
  2. sebastienp_unity

    sebastienp_unity

    Unity Technologies

    Joined:
    Feb 16, 2018
    Posts:
    201
    Hi Trisibo,

    A few information first:
    - To have properties be indexed, ensure your index settings is setup correctly:

    upload_2022-11-22_9-19-3.png

    - To iterate over SerializedProperty in order to index them, we use SerializedProperty.NextVisible (https://docs.unity3d.com/ScriptReference/SerializedProperty.NextVisible.html) which only iterate over public properties. I suppose if you would put your property public they would be properly indexed.


    Thanks,

    Sebastien


     
  3. sebastienp_unity

    sebastienp_unity

    Unity Technologies

    Joined:
    Feb 16, 2018
    Posts:
    201
    Can you log a bug for this using the bug reporter and attach your project (or a test project to it)? I would like to try toirepro this on my side.


    upload_2022-11-22_10-5-36.png

     
  4. Trisibo

    Trisibo

    Joined:
    Nov 1, 2010
    Posts:
    245
    I will try to send a simplified project. To clarify, I indeed have the "Properties" option enabled in the indexing settings, and the field is not public but it's serializable, which would be picked by "SerializedProperty.NextVisible", but in any case making it public doesn't work either.
     
  5. sebastienp_unity

    sebastienp_unity

    Unity Technologies

    Joined:
    Feb 16, 2018
    Posts:
    201
    Hi Trisibo.

    I have tested your use case in our latest Unity version (23.1) and in 21.3.

    In 23.1 property indexing works fine and I am able to find all 3 properties.

    In 21.3 I have the same problem as you have. I will investigate further and try to find the root cause of those problems and see if we can backport the proper fixes to 21.3 (depending on the complexity of those fixes).

    Thanks for reporting the problem. I would also suggest you properly report the bug using the Bug reporter. This makes it easier for devs like me to track and to implement proper bug fixes. I will keep you in the loop if and when I find a proper solution.

    Seb

     
  6. sebastienp_unity

    sebastienp_unity

    Unity Technologies

    Joined:
    Feb 16, 2018
    Posts:
    201
    Just to clarify:

    In my testing backendid and alwaysAvailableInTestBuilds are working :

    upload_2022-11-23_10-24-31.png

    upload_2022-11-23_10-24-50.png

    But id is ignored. I will investigate why that happens:
    upload_2022-11-23_10-25-34.png


     
  7. sebastienp_unity

    sebastienp_unity

    Unity Technologies

    Joined:
    Feb 16, 2018
    Posts:
    201
    Also, If it is possible on your side, I would suggest you try the following things to see why "backenid" doesnt work:

    1- You can try to force rebuild your indexes using the Index Manager:
    upload_2022-11-23_10-33-16.png

    2- If it doesn't work, you can delete your <Project>/Library and restart search and see if it fixes the backendid issue.

    These types of mixed up shouldn't happen but I would be curious to see if the properties were initially badly indexed. Thanks for your patience @Trisibo .
     
  8. Trisibo

    Trisibo

    Joined:
    Nov 1, 2010
    Posts:
    245
    It seems the actual issue is not that the "backendId" property doesn't work, but that:
    1. The tool always displays the error "Unknown filter xxx" when there's no asset with the specified value for the property. For example, "t:caseinfo backendid=asdf" will display the error when there's no asset with the backend id "asdf", but when typing an existing value it will show the corresponding assets and no error.
    2. If there's no asset with a value for a property (say, all assets have empty strings for the backend id), the property won't be shown in the "Keywords" section of the search index manager window.
    That's rather confusing, specially point 1, since it seems as if you didn't write the property name properly.

    Regarding the "id" property, the issue seems to be just that it's one of the ignored properties specified in "Edit -> Preferences -> Search -> Indexing", so it will show an error even if there are assets with the specified value. Removing it from the list makes it work, although in this case, when writing a non-numeric value that no asset contains, the error message shown is "The value "xxx" could not be converted to any of the supported handler types", I assume because "id" is a built-in token to search GameObjects by their numeric instance id.
     
  9. Trisibo

    Trisibo

    Joined:
    Nov 1, 2010
    Posts:
    245
    I'm not sure if this warrants sending a bug report, or if we could treat it as just feedback.
     
  10. sebastienp_unity

    sebastienp_unity

    Unity Technologies

    Joined:
    Feb 16, 2018
    Posts:
    201
    I was about to tell you about "id".

    You are right that the error message when no results are found on a known filter (with a bad value) can be misleading but always check which Search Area tab is selected:


    upload_2022-11-28_13-49-44.png


    upload_2022-11-28_13-49-52.png


    Thanks for your feedback and patience.

     
  11. Trisibo

    Trisibo

    Joined:
    Nov 1, 2010
    Posts:
    245
    I see, but I'm using the "All" tab (which I don't see in your images, I assume that's a newer Unity version, but it's in Unity 2021.3.13). I think in that tab the error shouldn't appear, since it would still be a valid filter:

    upload_2022-11-28_19-59-2.png
     
  12. sebastienp_unity

    sebastienp_unity

    Unity Technologies

    Joined:
    Feb 16, 2018
    Posts:
    201
    You are right about this. Behavior might already be different in newer version. I will have to see how we can ensure proper error reporting on filter name.

    Thanks,

    Seb

     
  13. shinymerlyn

    shinymerlyn

    Joined:
    Sep 25, 2020
    Posts:
    13
    Edit: I got it working. I had to comment out the field initializer, remove the ignored field in the preferences, AND force a rebuild of the entire index. Now searching on the Id field is all working exactly how I'd expect it to. It works in the advanced search, though it doesn't work in the Project tab's filter field. I think this is expected tho.

    -----
    Before Edit:

    I'm running into the same issue on 2021.3.19. Specifically on a custom string `Id` property in my SOs.

    I have tried changing Edit -> Preferences -> Search -> Indexing, and removed `Id` from the "ignored properties" list and restarted Unity, then forced an index rebuild. That still didn't solve the issue for me.

    I tried several variations, with known existing data. I tried with a lower or pascal case for the property name, with a partial value or exact value, with quotes surrounding it and without, and with : or =. I also tried various combinations thereof, especially combos that work for other properties. In all cases, it says it finds no results.

    I did have an initializer on the Id field to generate a random initial id for new objects, but I tried removing that and it auto-updated the search index, and it still couldn't find it. I waited for that to complete. The underlying YAML has values for all these in my project, and after my change that serialized value is still showing in the inspector. Still shows no results in search with the above combinations.
     
    Last edited: Apr 20, 2023
  14. sebastienp_unity

    sebastienp_unity

    Unity Technologies

    Joined:
    Feb 16, 2018
    Posts:
    201
    Glad it works @shinymerlyn .

    Thanks for the edit.