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"));
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
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:
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);
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
Maybe you can do like Henrik describes here:
client.Search<VideoPage>() .For("\"5ianR5MTE6eMQIPw3iE1TjLqzW7No7_R\"") .InField(a => a.LegacyVideoId) .Take(1);
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
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)
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
When i change the q.Anaylzer = "keyword" as it is mentioned in elastic search but it does not return any value?