Hello everyone,
I am a newbie with Examine and Lucene.
I wanted to use them to query the cache instead of hitting the database.
It works! The search are performing well and quickly.
The only problem that I have is to build queries.
I want to focus my search on a specific 'nodeTypealias' and get all the 'nodeNames' connected. That was not particularly difficult. The problem started when I wanted to apply another filter to this selection and get only 'nodeName' starting with letter 'a' or 'b'.
This is my Web APi code:
public class PeopleApiController : UmbracoApiController
{
public IEnumerable<SearchResult> GetPeople(string letter = "") {
var Searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
var searchCriteria = Searcher.CreateSearchCriteria(BooleanOperation.Or);
var q = "nodeTypeAlias:PeopleDetails";
var query = searchCriteria.RawQuery(q);
IEnumerable<SearchResult> results = Searcher.Search(query);
return results;
}
}
How could I combine the part with wildcards like :
"nodeName:" + letter + "?";
I tried also to do something like:
public IEnumerable<SearchResult> GetPeople(string letter = "") {
var Searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
var searchCriteria = Searcher.CreateSearchCriteria("content");
var query = searchCriteria.NodeTypeAlias("PeopleDetails").And().NodeName(letter + "?").Compile();
IEnumerable<SearchResult> results = Searcher.Search(query);
return results;
}
using Examine.LuceneEngine.SearchCriteria;
(add this as a using statement to get access to the extension method)
eg
var criteria = searcher.CreateSearchCriteria();
var query = searchCriteria.NodeTypeAlias("PeopleDetails").And().NodeName(letter.MultipleCharacterWildcard()).Compile();
More documentation here on the Fluent Search API here
Umbraco Web Api with Examine Lucene question
Hello everyone, I am a newbie with Examine and Lucene. I wanted to use them to query the cache instead of hitting the database. It works! The search are performing well and quickly. The only problem that I have is to build queries.
I want to focus my search on a specific 'nodeTypealias' and get all the 'nodeNames' connected. That was not particularly difficult. The problem started when I wanted to apply another filter to this selection and get only 'nodeName' starting with letter 'a' or 'b'.
This is my Web APi code:
How could I combine the part with wildcards like :
"nodeName:" + letter + "?";
I tried also to do something like:
Hi Enrico
I think you are looking for the
MultipleCharacterWildcard()
extension method
in
using Examine.LuceneEngine.SearchCriteria; (add this as a using statement to get access to the extension method)
eg
More documentation here on the Fluent Search API here
https://github.com/Shazwazza/Examine/wiki/FluentSearchApi
Great Mark
it worked like a charm
Thanks again
Hi Mark,
thanks to your help I built a function that works great with letters.
This is the code, I hope it could be helpful to anyone that is dealing with the same feature
HTML CODE :
JQuery code :
The Api Controller Code :
is working on a reply...