Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Only search full word using For

Vote:
 

Hi,

I am trying to search for whole word but EPiFind returns many results whereas it should only return 1 result.

the keyword is 5ianR5MTE6eMQIPw3iE1TjLqzW7No7_R

  query = query.Search(x => x.For(videoPage.LegacyVideoId, q =>
                    {
                        q.Query = "5ianR5MTE6eMQIPw3iE1TjLqzW7No7_R";
                    }).InField(a => a.LegacyVideoId));

When i change the q.Anaylzer = "keyword" as it is mentioned in elastic search but it does not return any value?

#190218
Apr 05, 2018 6:57
Vote:
 

Hi Murtaza,

Is there a reason you need to use For()? If you're trying to get a single result based on an exact match of a query you could just use Filter(). For example:

client.Search<VideoPage>().Filter(x => x.LegacyVideoId.Match("5ianR5MTE6eMQIPw3iE1TjLqzW7No7_R"));
#190233
Apr 05, 2018 15:38
Vote:
 

Hi @Paul Gruffydd,

The reason for using For is because property may contain some extra info for e.g

Property LegacyVideoId can contain string like 5ianR5MTE6eMQIPw3iE1TjLqzW7No7_R|112345|Axuqlap1202-T

but I need to search for string 

5ianR5MTE6eMQIPw3iE1TjLqzW7No7_R

Or

112345

Or

Axuqlap1202-T

any of the search with above string should return back me that one result but it gives me many results.

Cheers

#190241
Apr 06, 2018 2:05
Vote:
 

Is it possible for you to change the model or change the index? My primary suggestion would be to split those values out into their own respective fields if they're supposed to be different pieces of data that should be matchable in the search. If you can't split the model by either splitting into three properties, or if that's not possible use the extension method way of adding fields to your index as explained here:

https://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Find/9/DotNET-Client-API/Customizing-serialization/Including-fields/

Then you can keep your model but index them in a way that makes it easier to use match as suggested by Paul above.

If none of that is an option you could also try Take(1). Unsure if it will work based on your data set but it's worth mentioning.

I'm unsure what "query" is supposed to be in your example, but using IClient you'd end up with this instead:

client.Search<VideoPage>()
.For("5ianR5MTE6eMQIPw3iE1TjLqzW7No7_R", q =>
    {
        q.Query = "5ianR5MTE6eMQIPw3iE1TjLqzW7No7_R";
    })
.InField(a => a.LegacyVideoId)
.Take(1);
#190286
Edited, Apr 06, 2018 22:20
Vote:
 

Hi @Jafet Valdez

I will see if I can break propety in to multiple properties or do something mentioned in customizing serialization docs in any way i will need to re index my pages.

Cheers

#190302
Apr 09, 2018 8:03
Vote:
 

Maybe you can do like Henrik describes here:

https://world.episerver.com/forum/developer-forum/EPiServer-Search/Thread-Container/2013/11/Searching-phone-numbers/

client.Search<VideoPage>()
.For("\"5ianR5MTE6eMQIPw3iE1TjLqzW7No7_R\"")
.InField(a => a.LegacyVideoId)
.Take(1);
#190307
Apr 09, 2018 8:53
Vote:
 

Hi @Henrik Fransas

I checked with above suggestion it still tokenizes the string

What i have found that the following request 

{"query":{"filtered":{"query":{"filtered":{"query":{"query_string":{"fields":["LegacyVideoId$$string.standard"],"query":"\"5ianR5MTE6eMQIPw3iE1TjLqzW7No7_R\"","analyze_wildcard":false,"auto_generate_phrase_queries":false,"default_operator":"AND"}},"filter":{"term":{"___types":"EPiServer.Core.IContent"}}}},"filter":{"term":{"___types":"NRL.Web.Business.Models.Pages.ArticlePage"}}}},"fields":["___types","ContentLink.ID$$number","ContentLink.ProviderName$$string","Language.Name$$string"]}

gives many results

even though the Language.None is passed and LegacyVideoId$$string.standard is set as standard not as LegacyVideoId$$string.en

If I remove the .standard from the request "LegacyVideoId$$string" and re-issue it then it does whole word search which is what i want. So EPiFind has bug even we specify the Language.None it still treats as english language and tokenizes it.

Cheers

#190347
Apr 10, 2018 4:24
Vote:
 

Hi Guys,

I have used below solution to trick EPiFind to do the whole word search using wild card search

string legacyVideoId = $"*{videoPage.LegacyVideoId}*";

                    query = query.Search(x => x.For(legacyVideoId, q =>
                    {
                        q.Query = legacyVideoId;
                    }).InField(a => a.LegacyVideoId)
#190432
Apr 11, 2018 8:11
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.