Search results are in an unexpected order when searching everywhere 关注
If I have a file named `Demo.spec.tsx` and `DemoFile.spec.tsx` and I search everywhere for `Demo.spec.tsx`, the exact file name match is not returned as the first result. I would expect exact file name matches to appear first on the list, but they don't. I've included a contrived example where the file is simple enough to find since there's only 2 files to return results from. But when I'm working in a larger project, the exact file match could be 10-15 files down the list. Is this expected?
Could you confirm which version of IDEA you are using? I've tried with IntelliJ IDEA 2022.3.2 (Ultimate Edition) Build #IU-223.8617.56, all works fine. Or you may share a minimum sample project without any sensitive data to https://uploads.jetbrains.com/.
Hi, I am also running IntelliJ IDEA 2022.3.2 (Ultimate Edition) Build #IU-223.8617.56, built on January 25, 2023. I just upgraded yesterday from 2022.1 and today when I opened up IntelliJ I could still reproduce this issue...but then it started returning results in the correct order. So I don't know if there were some processes that were still upgrading behind the scenes or if it was still quietly indexing files. But it is now working correctly and returning the expected result first.
Just ran into another instance in another project using the same build and version number where searching for the full name of a file does not return it as the first item in a list. Maybe it's an effect of upgrading and IntelliJ having to rebuild its search indexes and not notifying the user of degraded search results? But I have verified this has happened in 2 unrelated projects. The Demo project I initially took this screen shot from no longer exhibits out of order search results, but another larger project I have just opened up after upgrading is giving out of order results.
In the background implements, Search Everywhere's result is complex, it's built by different plugins and even third-party plugins can add things to it concurrently(for performance reasons), so if you first might only see partial search results in a big project then the result is increasing after sometime indexing, etc. More over, the order of a single plugin's result might be dynamically adjusted by itself, for example, the more clicked(or recently visited) item may have a higher priority in the result, and even machine learning will take effect in IDEA's built-in functions(see https://github.com/JetBrains/intellij-community/blob/idea/223.8617.56/plugins/search-everywhere-ml/resources/META-INF/plugin.xml ). So just in words in a complex project, the order of the results might not be guaranteed and might be changed from time to time.
Let me create simple figure for it:
------------ All Tab ----------
[Item a1, a2, a3...] // added by a thread and grouped together, order controlled by the plugin itself
[Item b1, b2, b3...] // added by a thread and grouped together, order controlled by the plugin itself
------------ Result Page End ----------
This will clear some machine learning results. Some results are based on the index engine in IDEA. So sometimes it might help with reindexing the project by clicking File > Cache Recovery.
Thanks for getting back to me. I understand everything here--but I think the problem is a little more niche than just returning general search results and the ordering of the results. It's demonstrated in my first post. When multiple files exist with the same prefix, Search Everywhere struggles to put the full string match that only includes the common prefix as the first result--even though it's a 100% match of the search query. That is the problem. If there's a 100% match of my search query, I would expect the result to be first and it is not.
I understand your question, by default, the Files tab's content order in the Search Everywhere dialog is adjusted very quickly. Turn off the based on machine learning options might make the result more predictable. Please check if it helps you a bit.
According to the documentation: https://www.jetbrains.com/help/idea/2022.3/advanced-settings.html#advanced_se , this will make the Sort search results on the Files tab using the standard ranking mechanism instead of machine learning .
Also in Search Everywhere, input Registry... to open the dialog and try disable something like: