I have a legacy Umbraco 4.7.1 install im working on and want to do some Ajax search using Examine.
I have this so far:
@using Examine.LuceneEngine.SearchCriteria
@using umbraco.MacroEngines
@using UmbracoExamine.SearchCriteria
@inherits umbraco.MacroEngines.DynamicNodeContext@{var searchQuery = Request["searchstring"];
var filterList = Request["filters"]; //1122,1133,1347var filterIds = newList<string>();
var searcher = ExamineManager.Instance.SearchProviderCollection["InternalSearcher"];
var searchCriteria = searcher.CreateSearchCriteria(Examine.SearchCriteria.BooleanOperation.Or);
var query = searchCriteria.Field("partnerTitle", searchQuery).Or().Field("shortDescription", searchQuery).Compile();
var searchResults = searcher.Search(query);
}@{foreach (var item in searchResults)
{
var nodeurl = Model.NodeById(item.Fields["id"]);
<div><p><ahref="@nodeurl.Url">@item.Fields["partnerTitle"]</a></p></div>
}
}
I can search via the 'searchstring' being passed to the page, but need to be able to search a MNTP associated to the nodes is property alias is 'attributes'
How would i build the query to search for attributes, i can pass a comma delimited string to the page - filterList
My search uses filters and a search box, passing values to a searchresults page:
My Search Page:
I need it to search not only the title, description but match on the alias attributes which is a MNTP:
The code above searches nicely when i pass a search term from the text box, but i cant get it to filter via the checkboxes which passes a sting like 1123,1345,1234
so i need it to search to see if the node contains the alias attribute and has that id selected within it
@using Examine.SearchCriteria
@using UmbracoExamine
@inherits umbraco.MacroEngines.DynamicNodeContext@{var searchQuery = Request["searchstring"];
var filterList = Request["filters"]; //1122,1133,1347var searcher = ExamineManager.Instance.SearchProviderCollection["InternalSearcher"];
var criteria = searcher.CreateSearchCriteria(IndexTypes.Content);
IBooleanOperation query = criteria.NodeTypeAlias("PartMark-Partner");
query = query.Not().Field("umbracoNaviHide", 1.ToString());
if (!string.IsNullOrEmpty(searchQuery))
{
query = query.And().Field("partnerTitle", searchQuery);
}
if (!string.IsNullOrEmpty(filterList))
{
string[] attIds = filterList.Split(',');
query.And().GroupedOr(newList<string> { "attributes" }, attIds);
}
var results = searcher.Search(query.Compile());
}@{foreach (var item in results)
{
var nodeurl = Model.NodeById(item.Fields["id"]);
<div><p><ahref="@nodeurl.Url">@item.Fields["partnerTitle"]</a></p></div>
}
}
Seems to pull back results that match in the attributes MNTP ids now :)
My only problem now is getting the 'searchQuery' string to match on a fuzzy basis, at the minute the case and word have to exactly match to bring back a result, is there a way to ignore case sensetivity and also partial words? i.e. contains chars of a word?
i.e. the search term Limited = 2 results
but, typing in Lim, lim, limi or any derivitive of that word would not return a result due to it not exactly matching
Examine - Multiple filters on an MNTP property
Hi
I have a legacy Umbraco 4.7.1 install im working on and want to do some Ajax search using Examine.
I have this so far:
I can search via the 'searchstring' being passed to the page, but need to be able to search a MNTP associated to the nodes is property alias is 'attributes'
How would i build the query to search for attributes, i can pass a comma delimited string to the page - filterList
but unsure how to build up the query.
Any help would be greatly apprciated.
Hi Neil what exaclty are you trying to search for?
Thanks,
Charlie :)
Hi
Im trying to implement a kind of faceted search
My search uses filters and a search box, passing values to a searchresults page:
My Search Page:
I need it to search not only the title, description but match on the alias attributes which is a MNTP:
The code above searches nicely when i pass a search term from the text box, but i cant get it to filter via the checkboxes which passes a sting like 1123,1345,1234
so i need it to search to see if the node contains the alias attribute and has that id selected within it
Ok think i have this working -
Seems to pull back results that match in the attributes MNTP ids now :)
My only problem now is getting the 'searchQuery' string to match on a fuzzy basis, at the minute the case and word have to exactly match to bring back a result, is there a way to ignore case sensetivity and also partial words? i.e. contains chars of a word?
i.e. the search term Limited = 2 results
but, typing in Lim, lim, limi or any derivitive of that word would not return a result due to it not exactly matching
Any ideas?
is working on a reply...