Try our conversational search powered by Generative AI!

Grasping right hand truncation (Girig högertrunkering) on all fields

Vote:
 

We are converting from SiteSeeker to EPiServer Find for a customer and I notised that they are using something in SiteSeeker called (Girig högertrunkering) witch means that it instead of searching only for [Hell] it does a [Hell] OR [Hell*] -search. Read more here :http://www.siteseeker.se/sv/kunskapsdatabas/faq/sokning/ordledsuppdelning/

I have looked into the solutions for achiving this in EPiServer Find and in all of them it's only for one property, I want to do it for all properties and for information in files and so on.

Is there even possible to do that in EPiServer Find?

 

 

#76234
Oct 21, 2013 16:01
Vote:
 

It should be since EPiServer has ElasticSearch that uses Solr and Lucene inside and Lucene supports it.

You can use Lucene Query Syntax (search text box is exposed in EPiServer Find CMS User Interface to let your try it out).

I guess the question is to get EPiServer Find to construct the query for you since it create an abstracts layer on top?

#76450
Oct 24, 2013 16:02
Vote:
 

Fredrik Haglund. You are right, the searches worked in the admin-textbox, for example prestigel* did find a object containing the word prestigelös. 

When I try it in code like this:

var searchQuery = SearchClient.Instance.Search<Jobbannons>(Language.Swedish)
.For(query + "*")

It does not work, so I guess that you are right that the CMS are not supporting it on its abstracts layer. So the remaining question is how to get it to do that.

#76517
Oct 28, 2013 9:10
Vote:
 

Looking into it a littel more I see in Fiddler that the CMS-integration escapes my "*" before it sends it the the find-server.
Searching for the same thing in admin gives this query to the server (tooked out only the important stuff)
"query":{"query_string":{"query":"prestigel*"}}

Doing it with For and SearchClient like this (.For("prestigel*")) gives the following query
"query":{"filtered":{"query":{"query_string":{"query":"prestigel\\*"}}

As you can see, the accual query sent through the form is prestigel\* not prestigel*

Maby it's a bug in Find or a feature, I don't know....

 

#76521
Oct 28, 2013 9:58
Vote:
 

I got some answer from Joel in this article:
http://joelabrahamsson.com/wildcard-queries-with-episerver-find/

I tried to do his solution and it worked but, it still is per property and even if I know it's might be a stupid thing to do, I wan't it om all properties, exactly as it works in admin

#76527
Oct 28, 2013 11:18
Vote:
 

I solved this myself by digging a little in the Find-dll'files.

It turned out that the ".For(" search method I am using a function called .Quote() to remove varius characters with \-sign. It is using this regexp:

static QueryEscaping()
{
QueryEscaping.SpecialCharactersRegex = new Regex("(\\+|\\-|\\&\\&|\\|\\||\\!|\\{|\\}|\\[|\\]|\\^|\\(|\\)|\\~|\\:|\\;|\\\\|\\?|\\*)", RegexOptions.Compiled);
QueryEscaping.QuotesRegex = new Regex("\\\"", RegexOptions.Compiled);
QueryEscaping.EvenNumberOfQuotes = new Regex("^(([^\"]*\"){2})*[^\"]*$", RegexOptions.Compiled);
}

 

I ended up creating a extendmethod that I named RightHandTruncationFor that does not replace these characters and puts a trailing * on the search string.

Here is the code:

public static IQueriedSearch<TSource, QueryStringQuery> GraspingRightHandTruncationFor<TSource>(this ITypeSearch<TSource> search, string queryString)
{
if (search == null)
{
throw new ArgumentNullException("search");
}

var str = (string.IsNullOrWhiteSpace(queryString) ? "" : queryString) + "*";

return new Search<TSource, QueryStringQuery>(search, (ISearchContext context) =>
{
var queryStringQuery = new QueryStringQuery(str);
context.RequestBody.Query = queryStringQuery;

if (context.RequestBody.Query != null)
{
var boolQuery = new BoolQuery();
boolQuery.Should.Add(context.RequestBody.Query);
boolQuery.Should.Add(queryStringQuery);
boolQuery.MinimumNumberShouldMatch = 1;
context.RequestBody.Query = boolQuery;
}
else
{
context.RequestBody.Query = queryStringQuery;
}
});
}

 

#76531
Oct 28, 2013 11:48
Vote:
 

Using Find 11 now and still no built in support for this...

#145011
Feb 23, 2016 18:46
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.