Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContentPicker and MultinodePicker give no searchresults when startnode is set #17

Open
mcl-sz opened this issue Feb 2, 2021 · 13 comments

Comments

@mcl-sz
Copy link
Contributor

mcl-sz commented Feb 2, 2021

Hi @bielu ,

One of our users noticed that the searchbox in the contentpicker en multinodepicker doesn't give any results when Novicell.ElasticSearch is used for searching.
We've investigated this with a clean StarterKit installation of Umbraco 8.10.2. The "Home"-node has an "Call To Action Link" property which uses the ContentPicker editor. We found out that no items can be found when a startnode is set in the configuration of the picker. If the startnode is not specified, the search works fine.

Both pickers do an API call to /umbraco/backoffice/UmbracoApi/Entity/Search, for example https://localhost:44351/umbraco/backoffice/UmbracoApi/Entity/Search?query=p&type=Document&searchFrom=umb://document/ca4249ed2b234337b52263cabe5587d1&dataTypeKey=3ece86aa-61ad-45d5-b1dd-8f02f25df949. When the "searchFrom" parameter is removed or set to "-1" the search gives results, otherwise it won't.

With startnode specified
afbeelding

Without startnode specified
afbeelding

We've tried to debug the reason why the searchFrom gives no results. It looks like the nodeId (-1,1104) is set in the Lucene query but for some reason it's not giving any results.
Could you please help us?

@bielu
Copy link
Contributor

bielu commented Feb 2, 2021

hi @mcl-sz,
I will look over weekend into that issue :)

@mcl-sz
Copy link
Contributor Author

mcl-sz commented Feb 5, 2021

I did some more research and figured out that the "-1" in the Lucene query is causing the problem so that no results can be found.
The query that is generated is :
+(+__Path:-1,1104,* +(nodeName:p^10.0 nodeName_en-us:p^10.0 nodeName:p* nodeName_en-us:p* id:p* __NodeId:p* __Key:p*) +__IndexType:content)
When I run this query in Kibana, no results are found.

When I replace -1 to *, results are found:
+(+__Path:*,1104,* +(nodeName:p^10.0 nodeName_en-us:p^10.0 nodeName:p* nodeName_en-us:p* id:p* __NodeId:p* __Key:p*) +__IndexType:content)

I only have basic knowledge of Lucene queries. Is -1 a special or an invalid value to use in a query?

@mcl-sz
Copy link
Contributor Author

mcl-sz commented Feb 5, 2021

It looks like the minus-character is causing the trouble. When the minus-character is removed, the query gives results as well:
+(+__Path:1,1104,* +(nodeName:p^10.0 nodeName_en-us:p^10.0 nodeName:p* nodeName_en-us:p* id:p* __NodeId:p* __Key:p*) +__IndexType:content)

@bielu
Copy link
Contributor

bielu commented Feb 5, 2021

@mcl-sz thanks for input, will look into over weekend! :)

@mcl-sz
Copy link
Contributor Author

mcl-sz commented Feb 5, 2021

Thanks @bielu! For now I have solved it quick and dirty by using a regular expression to escape all negative numbers in the query with a slash.

Query = Regex.Replace(_luceneQuery.ToString(), @"(\-\d+)", "\\$1"),

This may not be the best solution, but for now it works for us. If you later have time to look for a better solution, that would be nice, but for now our problem has been solved with this.

@bielu
Copy link
Contributor

bielu commented Feb 5, 2021

@mcl-sz we can't do that :), as you can have - as sign something should be not included :)

@mcl-sz
Copy link
Contributor Author

mcl-sz commented Feb 5, 2021

That true, as i said it's not the best solution but it now only escapes negative numbers, other query components with a - sign are not affected by this. It's just more a quick fix for us at the moment :)

We've included the source in our project, we don't use the NuGet package. Therefore it is not necessary for us to update your NuGet build. It was more to indicate that this will (temporarily) fix the problem for us and that you can look for a better solution when you have the time.

@bielu
Copy link
Contributor

bielu commented Feb 14, 2021

@mcl-sz I looked into that issue already 2 times and hmmmm tricky one :) as it looks like umbraco returns incorrect lucene query :)

@bielu
Copy link
Contributor

bielu commented Feb 15, 2021

@mcl-sz ok find out, that was case of analyser, I fix that in that commit:
d574160
can you check and comfirm it does work on your end?

@mcl-sz
Copy link
Contributor Author

mcl-sz commented Feb 15, 2021

Hi @bielu , unfortunately this doesn't work for us yet. I have removed the old indexes so that new ones are created on start. The indexes are filled but do not find any results when the start node is set.

@bielu
Copy link
Contributor

bielu commented Feb 15, 2021

@mcl-sz ok i looked more deeply into that look like that is handled magicly inside of lucene.net even if that is incorrect lucene query. :) will look how to resolve that :)

@mcl-sz
Copy link
Contributor Author

mcl-sz commented Feb 15, 2021

@bielu something wierd is happening when the query is passed to
var result = internalSearcher.CreateQuery().NativeQuery(sb.ToString())

https://github.com/umbraco/Umbraco-CMS/blob/230bf1052cde249587d4ce06a2fb23859094f414/src/Umbraco.Web/Search/UmbracoTreeSearcher.cs#L139

afbeelding

@bielu
Copy link
Contributor

bielu commented Feb 15, 2021

@mcl-sz and later examine is operating on not escaped values, so wtf :) need go more deeply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants