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;
}
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/73811-umbraco-web-api-with-examine-lucene-question