Unity search (quicksearch) inconsistent results

Sometimes are the results different after second run of the same query.
Sometimes are in different order.
Sometimes Search finds nothing on the first run (after script recompilation/domain reload), but does find something on the second run.

This is true for SearchService.Request API and also for Search window. Using Unity 2022.3 LTS.

When I do first search after script recompilation, I notice that for a split second this background tasks pops up and then the search fails to fetch any results:
9521419--1343071--upload_2023-12-10_23-48-10.png

Hi @Epsilon_Delta1 ,

If you can provide example of queries + a test project that would give us an idea of why these results can be different.

The progress bar you are showing pops when incremental indexing of assets happens. Generally it should happen if an asset has been modified, or if you start unity after having pulled from version control.

Here are some of the settings/parameters that can influence the results you are seeing:

1- The Search Providers specified in your searchContext defines what will be used to search:


When searching for assets Project (using our Asset Indices), ADB (powered by AssetDatabase) and Find (search on file on disk) can be used to gather results.

So depending on what you have enabled in your Search Window or how you setup your SearchContext you might have varying results.

If you want force a specific provider to yield results, you can specify directly as the first argument of the query:

2- Some options can be passed to the SearchProvider to further define how the search should happen

Thanks for your feedback, if you find anything that doesn’t make sense, do not hesitate to log a bug (with a project).

Seb

I was certainly not changing any settings between the subsequent searches. The problem is that after recompilation of the scripts, search index update is triggered when I run first search. When this search is synchronous (using API), it does not yield any results. I have fixed this to use async variant which seem to work alright.

As to why this happens in search window I don’t know, but it happens quite often. For example I have project tab using the new search, and it does not find all results until the second or even the third run (gif attached). This never happens with the old search.

If I find some time and if you think it would help, I can make a bug report, but I have seen similar posts on the forums dating back 1-2 years. It seems easily reproducible and prevalent behavior

9536155--1346209--example.gif

Hi @Epsilon_Delta1 ,

Quick question for the gif you have posted: this happens in the Project Browser (I thought you meant the Search Window). To help me narrow down the root cause of the issue I want to know which search engine your are using for the Project Browser: Classic (tried and true since 2003) or Advanced (powered by the search backend):

9537934--1346659--upload_2023-12-19_9-25-49.png

This will help me investigate the bug further.

Thanks,

Seb

As I wrote in this paragprah, I have specifically enabled the new (Advanced) search in the project tab. But same thing happens in search window.

Thanks for the clarification, I somehow missed the part about using Advanced Search in Project Browser. We will look at this bug in the coming days/weeks (thus after Christmas)

I’ve noticed a similar thing for a long time now. The quick search window will sometimes find files, and sometimes not, regardless of which providers I have setup. For example, if I search in the project view, and then click the ‘open in quick search’ button, the project asset will be found.

But if I open the quick search with Ctrl-K immediately after and type the exact same query, the asset won’t be found at all.

It’s baffling and very frustrating. :frowning: I’ve tried clearing the indexes / Library folder, but the behavior is the same.

I’ve noticed a similar thing. I was using the new Search feature to find prefabs containing a script component I was trying to remove from the project. After removing the script component from all prefabs, they continued to show up in my searches for that component. It was as if search never re-indexed. Seemingly nothing I could do would make the false search results stop showing up.

1 Like