Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Official Quick Search Preview

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

  1. IAndrewNovak

    IAndrewNovak

    Joined:
    Nov 29, 2013
    Posts:
    104
    Still have artifacts in Unity2021.1.3
     
  2. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Yes very good idea. I will add this.

    Yes since we use fuzzy matching, sometime we yield extra results at the end of the list in case you made a typo or something like that. You can discard result you do not care about. If they eventually show up higher in the list, then that would be an issue.

    Thanks for the feedback.
     
  3. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Is it stalling? Otherwise this simply mean that the asset database is processing 456 search index artifacts in the background process (known as the Asset Worker Process).

    If you feel the indexing is stalling, one suggestion is to cancel the background task using the X and then open the Window > Search > Index manager and rebuild the index.

    Some new stability fixes are about to land in 2021.1.
     
  4. IAndrewNovak

    IAndrewNovak

    Joined:
    Nov 29, 2013
    Posts:
    104
    Thanks for the reply.

    How can I discard the extra results? Will be nice to add an option in QSearch settings to restore legacy search results behavior.
    Extra results are more annoying than helping when we get +50-100 unnecessary results.

    Yes. It's stuck. Cancel is helped but from time to time it appears again.

    It would be so nice. Now QSearch so slow and annoying. I hope it becomes stable ^_^
     
  5. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Ok I understand, having a few more options in the search preferences to toggle on/off fuzzy search and other type of search options would that work for you?

    Ok I see. If you ever come out with a pattern and some repro steps that would really help us to resolve this case.

    Ok I am sad to hear that :( I was under the impression it was better overall now than before. With which version are you comparing that slowness?

    Thanks,
     
  6. IAndrewNovak

    IAndrewNovak

    Joined:
    Nov 29, 2013
    Posts:
    104
    Yes.

    So far, I have not found a pattern, but if I find it - I'll write it right away.

    You did not understand me. The solution is really more convenient than the old one, but not yet polished. In my opinion, it is a bad idea to redefine the search system for unity without choosing the old or new (for example, like in the input system) for the first time.

    Perhaps I am having problems because I have a lot of files in my project, and for small games, the QSearch works very well.

     
  7. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    You can always try to add exclusion patterns for things you never want to search using QS, i.e. 3rdparty stuff?

    upload_2021-4-15_15-23-2.png

    You can also play with the indexing options in order reduce was actually gets indexed on your needs:

    upload_2021-4-15_15-24-39.png

    Also, like I said earlier we have a compression fix that should land in the upcoming days/weeks that will reduce by a lot the number of elements being indexed (185292 elements in the screenshot above, but still provide the same search results).

    Thanks a lot for you feedback.
     
  8. IAndrewNovak

    IAndrewNovak

    Joined:
    Nov 29, 2013
    Posts:
    104
    Thanks. I will try to use these options.

    Nice. I'll be waiting for it. GL :)
     
    jonathans42 likes this.
  9. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    81
    I upgraded to the latest quick search package 3.0.0 preview 8 and now I am missing the Favorites View (the view where it shows all the saved queries for quick access) which previously worked and allowed me to really quick try out several different queries. To be specific, the view that is explained here: https://forum.unity.com/threads/quick-search-preview.635863/page-12#post-6905027
    Is there some setting to activate/deactivate that view?

    I am on Unity 2020.3.4f1
    quick_search_favorites_missing.PNG
     
  10. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Indeed, the default was changed to not show it by default. But you can easily toggle this either using F3 while the search window is focused or through the window options:

    upload_2021-4-19_10-9-29.png

    Once toggled you should get this back:

    upload_2021-4-19_10-10-5.png

    Then the system should remember it and keep it open for subsequent search sessions.
     
    johanneskopf likes this.
  11. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    81
    Thanks @jonathans42 for the super fast reply with the solution!
     
    jonathans42 likes this.
  12. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    81
    Searching for a prefab, that does not exist, yields the correct results (no results at all), but also produces a red error message "Unkown filter "ref"." on the bottom. The message let me believe that the syntax of the query is wrong, which it isn't.
    upload_2021-4-19_16-20-7.png
    Using the same query but with an existing prefab:
    upload_2021-4-19_16-24-0.png
     

    Attached Files:

  13. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    81
    1. Is it possible to search for matches containing a string completely and in order?
    So that e.g. "_nature" will match only assets that contain the full phrase, like "test_nature" but not "test_allnature"?
    In the documentation I could only find the possibility to use "!" and "=" for exact matches, but that's not what I want given that I do not know the full name in advance.

    In this screenshot, you can see that everything with "_nonnature" in the name is matched too
    upload_2021-4-19_20-33-32.png
    EDIT: I also just realized two additional things:
    2. The highlighting in the screenshot is only working on some of the matches. This seems off.
    3. my query contains "t:Material", but the results contain a prefab. Shouldn't the prefab be excluded from the results?
     
    Last edited: Apr 19, 2021
  14. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Yes :( This will be fixed with 3.0.0-preview.9

    This will also be "fixed" in preview.9 since we've disabled fuzzy match by default, i.e.

    upload_2021-4-20_8-12-35.png

    upload_2021-4-20_8-12-53.png

    Fuzzy match was often yielding too many results.

    Remember you can also use regex when that is needed to get better matches, here's a simple example:
    upload_2021-4-20_8-15-19.png

    That must be because that prefab embeds a material? For prefabs, we scan all sub assets and components and we index
    t:<type>
    for all sub objects to the prefab root document. Can you send me this specific prefab for inspection?
     
    Last edited: Apr 20, 2021
    johanneskopf likes this.
  15. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    81
    Awesome, looking forward to the new version!

    Oh wow, with Regexes I quickly solved my task, thanks so much! :)

    I see. Thank you for the explanation. It does indeed embed that material. Hmm.. this functionality is really great to have if you need to search inside prefabs. But in my case, I just want all the Materials (excluding prefabs that reference Materials). Is there an easy way command to exclude prefabs (basically the indexed dependencies?) from the search? EDIT: I just added the material extension to my search query as a quick solution.

    Will send it to you via PM ASAP.
     
    Last edited: Apr 22, 2021
  16. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    81
    For the file extension, I need to search for multiple possible endings. So my query would look like this:
    upload_2021-4-22_1-10-54.png
    If I now additionally preselect only audio clips, it suddenly does not yield any results anymore:
    upload_2021-4-22_1-5-52.png
    I made sure that the t:AudioClip isn't the issue given that this query still contains the asset I am looking for (the one ending with "_nature.wav"):
    upload_2021-4-22_1-9-19.png

    Am I missing something here?

    EDIT: I managed to get it working by swapping the query conditions around:
    upload_2021-4-22_22-21-2.png
     

    Attached Files:

    Last edited: Apr 22, 2021
  17. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    81
    I use a QuickSearch query to find the references to my audio file:
    upload_2021-4-22_22-42-51.png
    When I do the same via code I get this SearchItem as result:
    upload_2021-4-22_23-0-17.png
    Here we can see that the GameObject I am looking for is present in the data property. Now is there a way to find out which component of this GameObject actually references my AudioClip?
    (As can be seen in the first screenshot, the PlayAudio script references the "ambience_nature.wav". So I want to find out via code that the PlayAudio actually is the component that references my AudioClip.)
     
  18. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    p:
    is the project filter id. Provider filter id always needs to be first, try,
    p: t:AudioClip "nature..."


    Which API are you using? Are you fetching results async?

    Unfortunately not for the moment. We would need to add component objects to the SceneProvider results (the search item type for the scene provider are
    GameObject
    ). I'll keep note of this and see if that would be possible without parsing to much data.
     
    johanneskopf likes this.
  19. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    81
    I wrote you a pm with all the details as I had another question related to that anyways.

    Thanks! I already thought about the possibilities of how to approach this but the only way I know so far to deal with that is to iterate over all components using GetComponent<MonoBehaviour>() and then using reflection to iterate over the component properties to get to know which are of what type which is very slow and then looking at the value of the property and verifying it is the one that is actually referencing my AudioClip.
    But using indexed data would be way faster for sure.
     
  20. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    The issue here is that the query
    p:nature and t:Material
    is matching your prefab because of the component
    Set Skybox Material
    .

    upload_2021-5-6_15-6-58.png

    In QS,
    :
    is working like a
    Contains/IndexOf
    . If you want to remove any ambiguity, you can use
    =
    .

    i.e.
    p: nature and t=Material


    upload_2021-5-6_15-8-49.png
     
  21. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    Is it possible to search for method names in unity events?

    Here is an example, i would like to find all objects that reference this method. I need this because i would like to rename the method and find all objects that referenced it and fix the reference on the unity event.

     
  22. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi, we do not index all event function names by default. We do it for certain types, but not all of them. That said, you can add a custom indexer for your type to do such a thing (you'll have to re-index your project/assets).

    Here's a code example for Animation clips:

    Code (CSharp):
    1.  
    2. [CustomObjectIndexer(typeof(AnimationClip), version = 1)]
    3. internal static void AnimationClipEventsIndexing(CustomObjectIndexerTarget context, ObjectIndexer indexer)
    4. {
    5.     if (!(context.target is AnimationClip clip) || !indexer.settings.options.properties)
    6.         return;
    7.  
    8.     indexer.AddNumber("events", clip.events.Length, indexer.settings.baseScore, context.documentIndex);
    9.     foreach (var e in clip.events)
    10.     {
    11.         indexer.AddNumber("time", e.time, indexer.settings.baseScore, context.documentIndex);
    12.         indexer.AddProperty("function", e.functionName.ToLowerInvariant(), context.documentIndex, saveKeyword: true, exact: false);
    13.     }
    14. }
    15.  
    Then in the search window you should be able to query the objects using
    p: t=GameEventListener function:dieonoverlapbasic


    I hope this helps.
     
    oscarAbraham and iSinner like this.
  23. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Sorry, actually since this is a scene object probabaly, you might be better creating a custom scene query filter to find such property. See https://docs.unity3d.com/2021.2/Doc...roviders.SceneQueryEngineFilterAttribute.html
     
    oscarAbraham and iSinner like this.
  24. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    jonathans42 likes this.
  25. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Please share your
    SceneQueryEngineFilter
    if you create one. If it is generic enough, we can always include it with the other ones we have built-in.

    Thanks
     
    awesomedata likes this.
  26. greg-harding

    greg-harding

    Joined:
    Apr 11, 2013
    Posts:
    519
    hey Baste cc: @jonathans42,

    did you ever implement the right-click and search stuff you asked about? It seems like a fairly fundamental search: click on an asset and find out where in the project it's used. I saw that the 2.1 preview docs mention a syntax guid: / id: search type which I was hoping would do the trick. At the moment the fastest way for me to find guid dependencies is using a Sublime Text 'find in files' text search under the Assets folder.

    @jonathans42 I installed QuickSearch again because I was hoping to be able to easily search for specific assets/guids in the project, what scenes/prefabs they're used in, etc. We previously tried QuickSearch v1 but removed it due to some issues with Unity Editor launch times being painfully slow on some machines (never figured out why sorry, but removing QuickSearch fixed it). I was just testing QuickSearch v2 (v2.0.2) again to check how it performs and for a while it looked ok, but the indexing is really slow and on a MacBook Pro with 32gigs of ram and plenty of free space indexing scenes runs out of memory and fails to index. I also tried v3 preview 9 and it took ~4 hours to index our project, and even though it was running as a background task it was beachballing the editor constantly making it unusable.

    Obviously the indexing is working hard, but what are your broad expectations for how long various project sizes might take to index for the first time, ie. is 4+ hours reasonable or is something not right? Is there any way to work around the indexing process running out of memory? Is the index valid and/or will it attempt to reindex things that have failed?

    Thanks for any info.
     
  27. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,194
    Nope. We had a right click option already that runs git grep in the background. I was considering replacing it with the quick search option as it should have some advantages, but it never got important enough that I took the time.
     
    greg-harding likes this.
  28. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi, 4 hours seems like a lot of time! here's the metrics I have for a big project.

    For a project of ~100 GB, it can take up to 30-60 minutes to index the entire project with a minimal set of options. If we choose to index dependencies and all properties then it can take between 60-120 minutes.

    That said, in big project we strongly suggest to create multiple indexes and for each of them include/exclude stuff you do not want. In example you can exclude in the index all the folders for generated data, i.e.

    upload_2021-5-31_8-35-11.png

    We try to make the background indexing taking as few resources as possible, but maybe the asset worker process is HDD bound when loading many small assets.

    If by any chance you could share your project with us (in private), I would be able to run some benchmark and see what is going on and probably improve the overall indexing.

    Have you tried with >=2021.2?

    Also which option set are you using?
    upload_2021-5-31_8-40-51.png

    Sub objects should only be used in a very large project if you only really really care about indexing scene and prefab offline, otherwise I wouldn't suggest it as it can make your indexes grow very large without much benefits. Sub objects indexing is useful for CI, automated processes or for explicit scene patterns.
     
  29. greg-harding

    greg-harding

    Joined:
    Apr 11, 2013
    Posts:
    519
    Thanks for your followup @jonathans42 :) Ok, so ~4 hours is long but in the ballpark for a large project. After trying v3 I did return to v2.0.2 again to try to install the samples to test the dependency/find by guid stuff (the v2.1 and v3 preview docs could be out of date, but the samples mentioned are not available in the package manager for those preview package versions). I couldn't get search by dep: or id: working though so I must be missing an installation somewhere.

    My current project folder (with a bunch of extra builds and other stuff under it) is ~30gig at the moment. The indexing kicked off before I did anything with the search manager, and to be honest I only found the search manager when I went through this thread and saw it mentioned - I did not see it in the docs. The Assets index ended up at 117meg, has just over 5 million elements with ~12k docs, and had Files, Types, Properties and Dependencies checked.

    I also tried a Scenes index and it ended up at 1.5gig, has ~64 million elements, 242 docs, 455k objects and had Files, Types, and Dependencies checked (they were the default options). At the end of this index the console showed 150+ out of memory warnings indexing all sorts of differently sized scenes. So, out of the box perhaps I needed to change some of the default options.

    When I tested v3 preview 9 I didn't have any search manager stuff open or configured. It just did whatever it did in the background process for the ~4 hours after installing the package. Unity was unusable while indexing and the activity monitor showed cpu at 100% and Unity not responding for long periods of time. In between these stalls it the background process view was showing it processing about 1 object per second, and about every 10-20 objects it would stall again.

    And sorry, I should have mentioned in my earlier post, this was all using Unity 2020.3.9. I have not looked at 2021.x tech stream as this is a shipping project.
     
  30. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    You are right the samples are not in 3.0.0 anymore. I'll see if we can fix that.

    This issue has been fixed in >=2021.1. Usually the search indexing shouldn't start until search is used the firs time. But in <=2020.3 there is an issue with the Project Browser, loading/importing every assets it see to get its thumbnail. Maybe we should backport the fix to 2020.3 (let me check with the team).

    We added some element compression in 3.0.0-preview.9 and >=2021.2 so maybe this might be fixed? That said, in very large project we do not recommend indexing all scenes and prefabs. We did some improvements around sub object indexing in >=2021.2, but it still make the search indexes very large. We'll continue to improve the sub object indexing in upcoming versions.

    Ok there is probably something unexpected going on. In order to try to solve this one we'll have to get a project that repro this case. I'll continue to investigate on my side with large project we have access too.

    I fully understand. If you ever try your project with >=2012.2 please let me know if search indexing seems to go faster and stall the main process less frequently.

    Thanks,
     
    greg-harding likes this.
  31. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    290
    Hello, I was wanting to try taking advantage of the indexing of assets that QuickSearch does, for use in my own tool. But for the life of me I cannot figure out how to access the API. I looked, but didn't see anything on the docs.
    I'm sorry, I'm sure I am just missing something really obvious.

    Appreciate any help, thanks. :)
     
  32. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi, let us know more exactly what you want to do and maybe we can provide you better examples, meanwhile you can find the API for Search at https://docs.unity3d.com/2021.2/Documentation/ScriptReference/Search.SearchService.html

    Currently the API to manipulate indexes (search database) is pretty limited. 2022.1 will have a new API,
    SearchService.CreateIndex(...)
    to dynamically create indexes. For now you need to create the indexes by writing a JSON file in your project. Here's an example to do that.

    https://github.com/lochrist/com.uni...b6c7c89f6abd25ce20a/Editor/CreateIndex.cs#L11

    Thanks,
     
  33. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    290
    Ah, thank you! I was trying to find a namespace with `QuickSearch` in it. That explains it!
    Does an equivalent API for searching exist in prior versions to 2021?

    I am making a tool that lets you group assets in to collections/tags, and I wanted to add a 'smart collection' that adds items to itself based on filters. Basically a glorified wrapper around QuickSearch :p
     
  34. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    You can use com.unity.quicksearch@3.0.0-preview.10 in 2020.3 with an equivalent API. API in version <=2.0.2 or not maintained anymore.

    We are currently prototyping something similar in 2022 (not official yet). The idea is to load collections from search query.

    See https://github.com/lochrist/com.uni...edb6c7c89f6abd25ce20a/Editor/SearchCollection for an old prototype. The work has been moved to 2022. We will provide more info later this year bout Collections if it becomes official.

    upload_2021-6-3_17-22-3.png
     
    Last edited: Jun 3, 2021
  35. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    290
    I see thanks, so there is no equivalent API available in 2019.4?

    Cool! I hope it becomes official!
     
  36. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
  37. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    290
    I was testing to see if it would make sense to switch my own system over to just using QuickSearch, and doing an initial test I noticed that it seems to lag when doing the very first search request after domain reload, but is very fast after that. Is this known? Am I doing something wrong? Is there some way to 'initialize' QuickSearch to prevent the lag?

    This is all I am doing.
    Code (CSharp):
    1.  if (GUILayout.Button("Query Cube"))
    2. {
    3.             _queryText = "Cube";
    4.             _items.Clear();
    5.             context?.Dispose();
    6.             context = SearchService.CreateContext(SearchService.Providers, _queryText);
    7.             SearchService.Request(context, (_, items) =>
    8.             {
    9.                 _items.AddRange(items);
    10.             }, _ =>
    11.             {
    12.                 context?.Dispose();
    13.             });
    14. }
    Any inside it appreciated :)
     
  38. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    290
    I was also wondering if someone could tell me how fast a request or partial request takes for large projects. Or point me to where I could find that info. I have 10k files that I use for testing, and it returns the results very quickly for the(Great job on this, gotta love binary search and multi threading). But I was hoping not to have to make 50k - 100k+ files just to test it my self.
     
  39. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi, on the first request, the search service initialize itself and load the search databases and an incremental update might also happen if content has changed since the last execution. So yes, the first search might seems to take more time depending on your state.

    Your code snippet seems legit. You might want to post a message in the second callback to
    SearchService.Request
    in order to indicate that all the items are available (i.e. repaint the UI, etc.?).

    At the moment not really. The system is designed to only initialize itself on the first usage. If you have access to internal API you can always enumerate all search databases using
    SearchDatabase.EnumerateAll()
    .

    Like I said previously, the first request is usually the most costly, but other subsequent (basic) requests should take only a few milliseconds to execute (when the indexes are loaded).

    I once tested with a project of >=900K text files. The indexing was quite long! But the search query once the DB was loaded took around 150 ms (in the background). So basically, for large project you pay a lot of time when indexing, but then the query should execute fairly quickly. It is also important to properly setup the indexes in a large project to exclude stuff you do not care about when searching. Also use Sub Objects indexing with care in large project since they can make the indexes grow very fast without much added value from a user point of view.

    Thanks,
     
    MechaWolf99 and Lars-Steenhoff like this.
  40. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    290
    Alright got it. That makes sense!

    Oh good! I was wondering if you could maybe explain how the incremental items return work? I guess it isn't too important. I just like knowing how the systems work. Like when/how often does it return items?

    Nice, I appreciate you sharing this info and helping me!

    Got another less technical question. How do you find items based on if their name contains a string? Using `name:` only matches to the front. And I saw in a comment from last year that you don't do a `string.Contains()` for performance reasons. However just entering a string in to the search field will return items as long as they have the string in their name, not just the front.
    So, how do?
    (Also if there is anything that would be helpful for me to do or let you know about, please let me know)
     
  41. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi, since the
    SearchService.Request
    API is fully async, there is one callback that receive batches of items that you can store in some list (see below for why we have multiple batches), start displaying them and when the second callback is invoked, it means that all search items were fully yielded. The reason behind that is that we do not cache search results as they are found, so we simply forward them to the user code and it is up to you to do whatever you want with them.

    We process multiple batches of search items for the following reasons:
    - A search provider can run in a background thread or process and yields search results in small batches to the main editor thread.
    - Even if a search provider is not multithreaded, like the
    SceneProvider
    , we do small batches of 25 ms to search objects in order to not stall the UI thread for too long, therefore every 25 ms we send batches of items, etc.
    - That said, it is possible that all items are sent in the first batch, ending the request right away, but that is not a guarantee.

    If you do not care that much about processing all the batches yourself, you can use the version of
    SearchService.Request
    that has a single callback that received the
    IList
    of all items. See,

    Code (CSharp):
    1.  
    2. [MenuItem("Examples/SearchService/Request All")]
    3. public static void RequestAll()
    4. {
    5.     SearchService.Request("t:texture", (SearchContext context, IList<SearchItem> items) =>
    6.     {
    7.         Debug.Log("All Textures");
    8.         foreach (var item in items)
    9.             Debug.Log(item);
    10.     }, SearchFlags.Debug);
    11. }
    Indeed
    name:
    does not work with partial matches (this is the case for many
    filters:
    compared to search
    words
    ), that said, you can use a regex to only match the last part of a name, i.e.

    p: ".+Critter[^/]+$"


    upload_2021-6-9_8-25-44.png
     
  42. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,449
    I wonder what the reason is why the search results don't get cached?
    Would it not make them faster?
    or is comparing the cache with the current search taking up the same time as doing a new search?
     
  43. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    This is only when using the API. That is not the case with the Search view. The reason is mainly to reduce memory footprint and stream results faster. That said, it is still possible that a specific search provider still cache data internally, but the search service won't create another copy of the data just for streaming it.

    Not really, because each search provider is still responsible to manage their respective database, so it is up to the various search provider to use a proper caching mechanism (e.g. which is the case for the asset provider).
     
    Lars-Steenhoff likes this.
  44. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    290
    Thank you vert much for the info!

    I see, thanks! Regex seems to be much slower, and possibly hangs the UI? Is it single threaded?
    Forgive me, I looked all over the docs but could not find the `select{}` expression/filter and when trying to use it my self it says a handler needs to be set first. Is there somewhere I can read more about this?

    As I am working with QS I am finding it actually rather difficult to get the exact results I am looking for. It does a lot of 'smart' search stuff, which is really, really nice when trying to search for something in the editor and works great! But I am finding it to be quite hard when working with the API to get just the items I am wanting.

    Part of this is that there are multiple filters that do exactly the same thing, or very close to the exact same thing, so it can be hard to figure out which one to use where. And part of it is the docs I think. Having more examples of how each filter can (and can't) be used would help, and more exact description of what they do and don't return.

    An example of this would be trying to only get items that are in a folder at a certain path.
    First I thought
    dir:
    would be the proper filter, but it doesn't accept a path, only a single folder name. Then I realized that
    p:<folder path>/
    would work (making sure to end with a forward slash). It does the exact same as
    find:
    and
    dir:
    also does the exact same, but less as long as you end with a forward slash. (Genuinely not sure the use-case of
    dir:
    )
    There is also
    t:folder
    which I can't get to work, but seems rather pointless, along with that is
    t:file
    which does the same as
    find:
    and
    p:
    I think?

    I assume the reason for the redundancy is that different providers/filters have these since the user can chose which to add/remove. But it makes it a bit harder to learn when trying to get precise results.
     
  45. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi, I understand your concern. I do not have any quick solution to that other than adding more filters to narrow down your search results.

    You can check this guide for more details about available filters: https://docs.unity3d.com/Packages/com.unity.quicksearch@3.0/manual/search-syntax.html

    Search expression and the new search table is only available in >= 2021.2. Documentation will be available in the upcoming weeks/months.
     
  46. TheGamery

    TheGamery

    Joined:
    Oct 14, 2013
    Posts:
    92
    Is there a way to stop this updating during play mode? Makes game unresponsive for ~5 seconds.

    I am using 2019.1.9f1.

    upload_2021-6-10_13-11-52.png
     
  47. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi, which version of the package are you at? I can double check. but I think at 3.0.0 indexes should only get loaded if you open the search window. Is it possible that the window is still open by the time you enter play mode?
     
  48. TheGamery

    TheGamery

    Joined:
    Oct 14, 2013
    Posts:
    92
    I don't think I have Quick Search package installed just the one that comes with 2021.1 (they look the same) so I don't know which version that is, I checked the package manager and couldn't find any reference to an installed Search package in Built-in/MyAssets/Unity Registry etc.

    I never really use the Search window, I only noticed it as I was getting the issue in play mode.
     
  49. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    290
    Hello,
    I have been trying to make an asset filtering system wrapper around QS, but I am running in to a problem.
    It seems that you cannot do use the OR operand with paths? For example
    p:assets/plants/ or p:assets/creatures/
    . My goal is to find all assets that are in either of those paths. Please let me know if I am doing something wrong, if this is simply not supported.

    (The more I test, it seem that the
    p:
    must be first? If that is the case that is a problem for me as you can see since I need to do two of them)
     
  50. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    I have issues searching objects in hierarchy that have names with spaces.

    For example, i have an object in hierarchy

    This is what it finds:

    the object in question is not found for some reason.

    Also, when i try to find references to an object with the name 'Panel - Options Menu' it finds nothing.

    Am i doing something wrong? any help is appreciated.

    QS version:


    P.S. I have searched this thread for anything related to the word 'space' and found nothing relevant.
    P.P.S. The scenes are indexed.