Search Unity

Official Quick Search Preview

Discussion in 'Editor Workflows' started by benoitd_unity, Feb 26, 2019.

  1. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    294
    Thank you for your help. I got it working using
    \/START_OF_FILENAME.[^\/]+$

    This will match only the start of the file name in a path. I feel like it could be cleaner, and truth be told I am still not 100% I know how it works. I had to add the period after the search text to exclude folders, but I don't think that should have worked... ehh I got it working and that is what matters in the end really.
    Thank you for your help
     
    jonathans42 likes this.
  2. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    294
    When doing a search through the API, is it possible to limit to only search a single provider in increase performance (in this case the Project/assets)? It looks like I can, but I couldn't figure out how to get just the project provider.
     
    Lars-Steenhoff likes this.
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    So the asset index starts updating every time I run a PlayMode Unit test through the test runner.

    If I were to guess why this happens, it's probably because those tests are implemented (by Unity!) by creating a temporary scene asset in the Assets folder, loading that scene, and then entering play mode. Or entering play mode and loading that scene, I can't quite remember.

    This is annoying for several reasons:
    - It's unnecessary work that might slow down other things.
    - It shows a load bar for the unnecessary work.
    - It takes a very long time (like a minute? Other changes doesn't cause that kind of issue at all).
    - Quick Search itself gets very slow when I try to open it after the test (probably because it's in the middle of indexing or something?

    I'm not sure if this is a bug on your side or on the test runners side or simply an integration bug, but it gets pretty jarring. The ideal solution would be either if QS knew about those scenes and ignored them when they showed up or got deleted, or if the Test Runner told QS to stop indexing when the scene exists.


    I mean the ideal solution would be if we could tell Test Runner to not make those scenes but instead load a specific scene for the test because that's always what we do anyway, but I don't think there's been any substantial work done to the Test Runner for like a couple of years, so I doubt it would happen?
     
  4. MrNickmik

    MrNickmik

    Joined:
    Nov 23, 2019
    Posts:
    2
    Hey! was recommended to post my issue here. Feel free to delete it if it's irrelevant to this post.

    I'm in a jam with our project's asset index and since I can't find any solutions or even anyone else who has this issue I think trying here might at least get me somewhere.

    As mentioned it's about our project's asset index, it often updates without getting anywhere and it takes a toll on the editor's performance and our development speed in general as we cant search or use plugins that need the asset index.

    Whenever Unity starts updating our asset index I can see it says "resolving artifacts x amount usually very high" but it never gains any progress or finishes no matter how long I leave it for. I also noticed that in the search index manager it says size 37b, 0 elements. I have no idea as to why this is a thing or how to debug or fix it but it would mean a great deal to us if this could be fixed.

    I have tried:
    - forcing an index rebuild
    - making another index
    - limiting the index to very a few folders
    - deleting my library and rebuilding it.
    - restarting unity makes the indexing stop but still no elements

    I hope you can help Kind Regards: Mikkel.
     

    Attached Files:

  5. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    294
    So, I did more testing and it seems that using the regex required is just too expensive for my use-case. I tried the CustomObjectIndexer, and it works (but not in my 2020.3 project), however it only works when matching the start of the name and doesn't support regex.

    For my asset which uses the search API it is not uncommon to have 4+ name 'contains' queries in a single search, so I would like to provide a more performant solution. Do you have any suggestions on a way to implement a fast 'name contains' lookup?
     
  6. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi,

    I will look into this. Please report a bug and share with me the case number so I can prioritize it.

    Meanwhile if you know in which folder the temporary scenes are created (or any other temporary assets) you can exclude this folder from the index settings so the system ignore those assets when they get created or updated.
     
  7. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Ok this sounds like an important issue. Can you share which version of Unity of the com.unity.quicksearch package you are using? We have fixed similar issues in the past and maybe updating to a more recent version might help.

    Thanks,
     
  8. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Can you share with me a more concrete example of what you want to search? What I understand is that you want in a single search to find 4 different assets with their name?

    If that is the case, with the new
    CustomObjectIndexer
    , e.g. lets suppose you've added the entry
    name:
    , you could do in a query the following:

    p: name:door22 or name:floor66 or name:room44 or name:door99


    This query should return you all the assets that have in their name indexed with
    door22
    ,
    floor66
    ,
    room44
    or
    door99
    .
     
  9. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    294
    Yes that is partly what I want. I want to also be able to find assets whose names contain certain things.
    Given your example, I want to do something like
    p: name:"or"
    to get all assets whose name contains
    or
    , like
    door22
    ,
    floor66
    , and
    door99
    .
    But I also want to do
    p: name:door or name:floor
    to get assets whose name starts with specified text.
    And lastly (or maybe it goes with wanting 'contains') I want to do to do regex, only on the assets name.

    Not sure if this helps, but I have this custom editor for creating searches. Each item in the list is a search entry, so it would create something like this. (It is more complex than this because I am using regex currently, but it illustrates it well enough I think)
    p: name:"tree" or name:"plant" or name:"flower"

     
  10. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    #1394039

    Well, they're created directly in Assets/. The name is InitTestScene + some guid (ie. InitTestScene637774892811600426.unity).

    I tried adding a regex to the exclude filter to catch it, but it doesn't seem like that's supported. I have this in there:
    upload_2022-1-11_9-24-49.png

    But the InitTestScene is still triggering the indexer.

    Thanks!
     

    Attached Files:

  11. MrNickmik

    MrNickmik

    Joined:
    Nov 23, 2019
    Posts:
    2
    Hey yeah we would love to have this solved, I believe we are using the newest version " Version 3.0.0-preview.22 - November 04, 2021 " our unity version is: 2020.3.4f1 URP.

    Kind Regards: Mikkel :)
     

    Attached Files:

    Last edited: Jan 14, 2022
  12. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Thanks I will look into this ASAP.

    These patterns are not regex unfortunately. You should simply use File with
    InitTestScene
    . If File is selected we simply check if the pattern is contained in the filename while gathering files to be indexed.
     
    Baste likes this.
  13. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    I have a hotfix. It will be in next version (22.2.0a2 or preview.24)

    I just need to evaluate performance risk.

    Thanks,
     
    Baste likes this.
  14. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    Adding InitTestScene to the exclude filter helped, so it's not very urgent for me! Thanks for that tip.
     
    jonathans42 likes this.
  15. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    294
    Did my example help make it clearer what I want? I guess another way to ask the question would be is there a way to use regex on a custom object indexer?
     
  16. Hjeldnes

    Hjeldnes

    Joined:
    Jul 22, 2012
    Posts:
    116
    Hi, I just discovered QuickSearch, and it looks pretty promising. I wonder, is it possible to easily only search for enabled/active gameobjects within the hierarchy? Something like h: bookshelf and p(isactive)=true
     
  17. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi, I believe that would be
    h: bookshelf active=true
     
  18. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    I do not think that is possible yet, but surely something we want to support.
     
    Lars-Steenhoff likes this.
  19. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    294
    Aw, that is too bad. Yeah that is something that would be very important feature for me as it would allow me to provide much better performance to my customers. Is there somewhere I should 'submit' it as feature request that would increase the chance of it getting added sooner (like we do with bugs)?
     
  20. sebastienp_unity

    sebastienp_unity

    Unity Technologies

    Joined:
    Feb 16, 2018
    Posts:
    201
    Lars-Steenhoff and jonathans42 like this.
  21. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Yes nice writeup!, Quick search is part of my everyday unity workflow, thanks for the great work!
     
    jonathans42 likes this.
  22. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,311
    Sorry if this has been brought up already, but is there a way I can find all objects that have missing references?
    I'd like the search to process all scenes, assets, prefabs etc.
     
  23. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi, it is still experimental, but you can try the Search Dependency Viewer for that.
    See https://github.com/Unity-Technologies/com.unity.search.extensions/wiki/Dependency-Viewer

    Otherwise if you only care about missing missing scripts, you can try https://github.com/Unity-Technologi.../blob/main/package/Indexing/MissingScripts.cs
     
    Lars-Steenhoff and CDF like this.
  24. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,311
    Oh yeah, forgot about the dependency viewer. Thanks
     
  25. Cerberus_team

    Cerberus_team

    Joined:
    Apr 9, 2014
    Posts:
    43
    Hi,
    When i type:
    t: prefab l:SciFi l:Building
    Every prefab with a SciFi OR a Building label will show up in the search results, is there a way to have an "AND" so that only prefabs with both label show up?
     
  26. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,295
    How is one supposed to install this?

    com.unity.quicksearch results in

    error.png
     
  27. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,295
    Can you please update your post about how to install this?
     
  28. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    294
    In case you are still wondering, in 2020 it is in the package manager by default. However there is a more updated version that is in preview, so you will need to enable preview packages to see the 3.0 version. In 2021.1 and newer, it is just built-in the editor and there is no need to add it at al.
     
    Rowlan likes this.
  29. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,295
    That first post should be updated
     
  30. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    AND
    is implicit, in order word the default. That said you can still type is, i.e.

    t:prefab AND (l:scifi AND l:building)


    So if I understand correctly, you are getting some results that have the label
    building
    , but not necessarily the label
    scifi
    ? If that is the case, it looks like an indexing issue. Could you report a bug with a sample project that repro the case?

    Thanks,
     
  31. Cerberus_team

    Cerberus_team

    Joined:
    Apr 9, 2014
    Posts:
    43
    I' am getting all prefabs with the "building" label plus all prefabs with the "scifi" label.

    I was asking if there was a way to ONLY show prefabs which have both labels.(Not one or the other)
     
  32. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    Okay, I'm running into problems. Quick Search is getting slower and slower, and I can't quite tell why.

    What seems to happen is this, but I'm speculating:
    - I have made a change to some prefab, scene, or whatever. I hit ctrl+s to save.
    - "Updating asset search index" starts spinning. For a long time - even if I have just saved a single scene, it gets stuck at 99% for everything from 2 to 10 seconds on merging changed:
    upload_2022-2-8_15-35-5.png
    - I open Quick search and start typing. It's initially responsive
    - Suddenly, Quick search and Unity hangs for quite a bit:
    upload_2022-2-8_15-32-15.png
    - Quick search comes alive again.

    What I suspect is that the hang is due to the search index being finished updating in the background, and then something happens that breaks everything.

    Any idea what's going on here? Here's a deep profiling result of doing the same (when it hangs in the last screenshot), and since it's deep profiling things are taking way longer than usual, but:
    upload_2022-2-8_15-41-43.png
     

    Attached Files:

    solkyoshiro likes this.
  33. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    This looks problematic indeed. Which version are you using exactly? I'll try to repro the issue based on the steps you have described. If you ever have a project that repro the issue more easily please share it with me in private.

    At a glance it looks like a locking issue from the main thread and maybe the indexing thread that was triggered when you saved the scene.
     
  34. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    Unity 2020.3.26f1, Quick Search is: "com.unity.quicksearch": "3.0.0-preview.22",
     
  35. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Are you using Sub Objects (or Extended) when indexing? If so, sub objects indexing have a much higher cost for scene assets.

    upload_2022-2-8_14-56-20.png

    That said I think I have an idea what could be going on. I'll send you a patch to try out after I am done with my testing. It seems
    SearchIndexer.GetDocument
    has a lock that doesn't resume until the incremental update is finished therefore locking the main thread too long.
     
  36. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    Looking forward to the patch!

    What I've got is this:
    upload_2022-2-9_8-47-34.png

    So no sub-objects. I don't know if the object or asset count is bad, doesn't seem like it should be? Though it is surprising that the number of elements in Assets to the left is more than 3 times the number of assets and objects?
     
  37. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    The index size is reasonable. That said, I wonder what are all the sub objects you have indexed (i.e. 64097-20880=43217) since you do not have Sub Objects enabled. Maybe some of these sub assets should be ignored.

    I have sent you a private message to get more info.
     
    Last edited: Feb 9, 2022
  38. austinborden

    austinborden

    Joined:
    Aug 5, 2016
    Posts:
    24
    Is there a way to always search with "Show Packages results" on? It seems to reset every time I do a search and I don't see any options in the Preferences. Using Unity 2021.2.11.

     
  39. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    It should stick just like Show more results. If that is not the case, could you report a bug so we can prioritize it.

    Note that the Show Package results flag is not used by all built-in search providers. Currently it is used by the Asset Database (legacy) and Files (find:) provider. The reason that the Project (p:) provider is not using it, is because you can customize your indexes as you want and include or exclude packages (See Window > Search > Index Manager)

    Thanks,
     
    austinborden likes this.
  40. solkyoshiro

    solkyoshiro

    Joined:
    Aug 25, 2021
    Posts:
    27
    I'm having this same issue. Quick Search is dragging my Unity down. Then if I try to open the Index Manager while its stuck on "Merging Index" it freezes up Unity.

    I'm on 2021.2.12.f1 and using HDRP.
     
  41. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    This issue has been fixed in 22.2, 22.1 and com.unity.quicksearch@3.0.0-preview.23

    The fix should land in 21.2 anytime soon.
     
  42. BunnyViking

    BunnyViking

    Joined:
    Nov 28, 2019
    Posts:
    17
    Search isn't returning all results (using search in 2021.2.14). It was suggested I bug it and report it in this thread.

    1409878_gdbvjv2sjpa0mrv7
     
  43. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi, I assigned the bug ticket to myself. I am not sure to understand what is shown above compared to below in the following screenshot?



    Would you be able to zip a sample project that repro that case and share it with me?

    Thanks,
     
  44. BunnyViking

    BunnyViking

    Joined:
    Nov 28, 2019
    Posts:
    17
    Top image is quick search
    Bottom image is asset search

    The project i encountered it in is huge but i can see if i can reproduce it in a leaner form
     
  45. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Ok I am not sure when you say top is quick search, they both seems to be quick search windows. Could you retake the screenshot and display the status bar so we can see which search providers are being executed:

    upload_2022-3-11_8-9-46.png
     
  46. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Ok I found the issue. Folder exclude patterns are wildcards and not exact match, so the folder name Ancient Set - Temples is conflicting with the default Temp folder exclude pattern.

    The work around for now would be to remove the Temp Excludes Folder pattern in the Index Manager (
    Window > Search > Index Manager
    )

    upload_2022-3-14_8-21-11.png

    Once you have removed this exclude pattern

    upload_2022-3-14_8-23-29.png

    You should now get more results.

    upload_2022-3-14_8-24-10.png

    We'll see on our side if we should remove the default
    Temp
    exclude folder pattern or maybe rename it to
    Assets/Temp
     
  47. BunnyViking

    BunnyViking

    Joined:
    Nov 28, 2019
    Posts:
    17
    Oh! Interesting. That explains why it was only some things not showing up. I didn't know about those exclusions so I'm glad you found it
     
    jonathans42 likes this.
  48. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    I mean you're making a very big assumption on behalf of the users when you're picking some folders and saying "yup, they probably don't want folders with these names indexed". Afaik, neither Temp nor External are special folder names in any other contexts than this, so honestly I think it's just a bad call to have anything there by default.

    It's also surprising that the names are patterns rather than just folders. Having access to patterns is very useful, but when we have a button that allows us to select a folder, having that name be interpreted as a pattern is in no way intuitive. There's nothing else in the UI to indicate that the name is a pattern.

    What I would prefer would be to have four options for excludes; files, folders, extensions, and regex. The other ones would be exact matches, while regex would be all the pattern goodness I might want. Then there's no ambiguity about what's what.
     
    JoNax97 and jonathans42 like this.
  49. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Indeed. That was a bad decision. I'll remove the defaults.

    Yes! I just logged a story about this and I'll add regex support ASAP and the other pattern types,
    extension
    ,
    name
    and
    folders
    will be non-wildcard matches (or complete match if you prefer).

    So if one sets an include or exclude rule, he'll be able to use a regex to to something like .
    +Temp.+
    to exclude anything that has Temp in its file path.

    So quick fix will be to remove the default patterns and we'll try to have in the next version support for regex include and exclude patterns.

    Thanks for the feedback.
     
    BunnyViking and Baste like this.
  50. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    294
    @jonathans42 So I have run in to another issue. QuickSearch has all of a sudden stopped completing searches, so they run infinitely. I have reported the issue with case number 1417609.
    It currently is only doing it on one project for me, but another user has also reported running in to the issue (Link to other user running in to it). I was unable to repro it on a fresh project unfortunately, so I am not sure how possible it will be to track it down. Let me know if there is any additional info or files you need.

    There are a number of times when QS doesn't seem to update the index and requires being rebuilt. When this happens should the issue be reported, and if so is there anything specific that should be included?