I using examine for searching with a single character.Means I have a property named Firstname in my node and I have more than 100 nodes in my umbraco ,I trying to search all first name start with A and disply,so I using examine to impliment this.But it dosn''t return the values.here is my code.Can anyone help?.
var contentSearcher = ExamineManager.Instance.SearchProviderCollection["WebsiteSearcher"];
var searchCriteria = contentSearcher.CreateSearchCriteria(UmbracoExamine.IndexTypes.Content, BooleanOperation.And);
List<SearchResult> contentResults = new List<SearchResult>();
string keyword = "";
string[] contentSearchFields = {"firstName"};
keyword = "A";
var luceneString = "";
if ((!string.IsNullOrEmpty(Request.QueryString["keyword"])))
{
if (!string.IsNullOrEmpty(keyword))
{
var keyWordQuery = "";
string finalKeywordQuery = " +({0})";
keyWordQuery += "lastName:" + keyword + "~0.3 ";
luceneString += string.Format(finalKeywordQuery, keyWordQuery);
luceneString += "+umbracoNaviHide:0";
}
var fquery = searchCriteria.RawQuery(luceneString);
contentResults = contentSearcher.Search(fquery).ToList();
The first letter search needs to be wildcard and not fuzzy so it should keyword +"*" get rid of the fuzzy bit. Also any reason why you are not using the fluent api?
Examine Search with a single character.
I using examine for searching with a single character.Means I have a property named Firstname in my node and I have more than 100 nodes in my umbraco ,I trying to search all first name start with A and disply,so I using examine to impliment this.But it dosn''t return the values.here is my code.Can anyone help?.
var contentSearcher = ExamineManager.Instance.SearchProviderCollection["WebsiteSearcher"]; var searchCriteria = contentSearcher.CreateSearchCriteria(UmbracoExamine.IndexTypes.Content, BooleanOperation.And); List<SearchResult> contentResults = new List<SearchResult>(); string keyword = ""; string[] contentSearchFields = {"firstName"}; keyword = "A"; var luceneString = ""; if ((!string.IsNullOrEmpty(Request.QueryString["keyword"]))) { if (!string.IsNullOrEmpty(keyword)) { var keyWordQuery = ""; string finalKeywordQuery = " +({0})"; keyWordQuery += "lastName:" + keyword + "~0.3 "; luceneString += string.Format(finalKeywordQuery, keyWordQuery); luceneString += "+umbracoNaviHide:0"; } var fquery = searchCriteria.RawQuery(luceneString); contentResults = contentSearcher.Search(fquery).ToList();
var results = contentResults;
Arun,
The first letter search needs to be wildcard and not fuzzy so it should keyword +"*" get rid of the fuzzy bit. Also any reason why you are not using the fluent api?
Regards
Ismail
Thanks Ismail.It is worked.I using raw query because,here I have some complex searching criterias,Raw query helps a lot,so... :)
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.