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

How to search Examine by Udi (content picker) property #291

Open
nickornotto opened this issue Sep 12, 2022 · 3 comments
Open

How to search Examine by Udi (content picker) property #291

nickornotto opened this issue Sep 12, 2022 · 3 comments
Labels

Comments

@nickornotto
Copy link

I am trying to query Examine by a content picker value - since it is an Udi then I need to provide Udi to the query. It looks like examine is not supporting it and splitting Udi value to bits by : and /

This is the query I get

Category: null, LuceneQuery: {+(+__IndexType:content +__NodeTypeAlias:product) +(categoryId:umb categoryId:document categoryId:671cf7620759444fa54ccaa2f23b8d2a)}

And this is how I add the property to the query:

searchQuery = searchQuery.And().Field("categoryId", "umb://document/671cf7620759444fa54ccaa2f23b8d2a");

How to lookup Examine index by a property that contains Udi?

I am using version 10.0.0 but I saw from other posts on the Umbraco forum that say the same thing is happening in Umbraco 8.

Not sure what happened to Examine but querying by Udi property worked well in version 7.15.3. we have the old site version working well.

@Shazwazza
Copy link
Owner

It's splitting because it's probably using the StandardAnalyzer on that field. If you want to search on UDI and you are storing UDI in a specific field, then you'd have to set that field type to be 'raw'

Else just search on the GUID part which is already indexed in the Key (or __Key - sorry can't recall off the top of my head) field with the correct field type set already

@nickornotto
Copy link
Author

I am using the InternalIndex for this purpose atm and it is using WhitespaceAnalyzer.

ExternalIndex throws the same error tbh despite it uses StandardAnalyzer.

It works with the key however it is not understandable how the same query that worked in Umbraco 7 cannot work in Umbraco 8-10?

Umbraco 10 does this when I pass Udi as the categoryId value:
LuceneQuery: {__NodeTypeAlias:product +(categoryId:umb categoryId:document categoryId:671cf7620759444fa54ccaa2f23b8d2a)}

so I need to use a key instead of Udi:

LuceneQuery: {+(+__IndexType:content +__NodeTypeAlias:product) +categoryId:671cf7620759444fa54ccaa2f23b8d2a}

If I use a raw query I am getting an error because of the colon in the value:

Cannot parse '+__IndexType:content +(__NodeTypeAlias:product +supplier:umb://document/671cf7620759444fa54ccaa2f23b8d2a -umbracoNaviHide:1) ': Encountered " ":" ": "" at line 1, column 61.

While Umbraco 7 was fine with this:

LuceneQuery: {__NodeTypeAlias:product +categoryId:umb://document/2ec733b1cbab4632b5ccf753b94b8105}

and it didn't see it as an error.

Or am I not building the raw query correctly?

@Shazwazza
Copy link
Owner

I am using the InternalIndex for this purpose atm and it is using WhitespaceAnalyzer. ExternalIndex throws the same error tbh despite it uses StandardAnalyzer.

Yes, both analyzers will tokenize terms based on punctuation, whitespace, etc... Standard will do more though.

__Key and anything prefixed with double underscore have a specific field analyzer set to KeywordAnalyzer (exact match).

You are searching on a custom field of categoryId so categoryId needs to be configured as a Raw Value Type - this is not the same as a raw query. A Value Type determines what Analyzer will be used for that field and how it is stored. There's documentation on this here and how to configure them and the available types that there are https://shazwazza.github.io/Examine/configuration

A raw query determines how the search terms is going to be tokenized before the search.

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

No branches or pull requests

2 participants