November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
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?
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.
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....
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
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;
}
});
}
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?