We want to create super fast and convenient search by multiple fields in our site.
We will have 10-15 search fields.
We want to use Angluar for client side, but we need some advice about server side logic.
Could you suggest some tips how create search mechanism ?
var searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
var criteria = searcher.CreateSearchCriteria(IndexTypes.Content);
var maxPrice = model.MaxPrice == 0 ? 100000 : model.MaxPrice;
IBooleanOperation query = criteria.Field(model.ActionName, 1.ToString());
query = query.And().Range("__price", model.MinPrice.ToString("D6"), maxPrice.ToString("D6"));
and this is gatheringNode event code:
private void OnGatheringNodeData(object sender, IndexingNodeDataEventArgs e)
{
// Create searchable path
if (e.Fields.ContainsKey("path"))
{
e.Fields["searchPath"] = e.Fields["path"].Replace(',', ' ');
}
// Lowercase all the fields for case insensitive searching
var keys = e.Fields.Keys.ToList();
foreach (var key in keys)
{
e.Fields[key] = HttpUtility.HtmlDecode(e.Fields[key].ToLower(CultureInfo.InvariantCulture));
}
// Lowercase all the fields for case insensitive searching
foreach (var key in keys)
{
int it;
if(int.TryParse(e.Fields[key], out it))
{
e.Fields["__" + key] = it.ToString("D6");
}
}
// Extract the filename from media items
if (e.Fields.ContainsKey("umbracoFile"))
{
e.Fields["umbracoFileName"] = Path.GetFileName(e.Fields["umbracoFile"]);
}
// Stuff all the fields into a single field for easier searching
var combinedFields = new StringBuilder();
foreach (var keyValuePair in e.Fields)
{
combinedFields.AppendLine(keyValuePair.Value);
}
e.Fields.Add("contents", combinedFields.ToString());
}
What vesrion of umbraco are you using? If 6 then can you install examine inspector, then in your code after search call can you get value of
criteria.ToString()
Then paste the query here and also run the query in examine inspector. One thing is that you have named your field __ i think examine reserves that and does not tokenise, it may be worth also from examine inspector looking at how the fields are stored.
I need to see how your fields are stored can you do a normal search in examine inspector and show me a screen grab of the fields then pick a record and click on it and show me a screen grab of how the fields are stored.
Price is not in d6 you have 2300 it should be 002300 what about _price which is what you have in your gatheringnode data code. Try running the query in examine inspector but on that _price field. Also can you show me screen grab of __price field and how that is stored.
I have done price ranges on http://www.world-of-incentives.com/programme-ideas.aspx and i have the price stored as d6 and when i query i use d6 i DID NOT store my field as _price as i think any field with _ will not be tokenised.
Multiple search fields
Hi Umbraco Comunity,
We want to create super fast and convenient search by multiple fields in our site. We will have 10-15 search fields. We want to use Angluar for client side, but we need some advice about server side logic.
Could you suggest some tips how create search mechanism ?
Thanks
Hello,
Have a look at the souce code of ezSearch. It's a search package which is very easy to use.
Jeroen
Hi Jeroen,
Thanks for you advice, I'm trying to do such search with Lucene, but have a lot of problems with Range search in numbers fields.
We saw this solution http://our.umbraco.org/forum/developers/extending-umbraco/11819-Examine-range-query-numeric?p=0, but it didn't help us.
Alex,
Can you paste code and explanation of what you are trying todo and what is not working?
Regards
Ismail
Its my controller:
and this is gatheringNode event code:
Alex,
What vesrion of umbraco are you using? If 6 then can you install examine inspector, then in your code after search call can you get value of
Then paste the query here and also run the query in examine inspector. One thing is that you have named your field __ i think examine reserves that and does not tokenise, it may be worth also from examine inspector looking at how the fields are stored.
Regards
Ismail
Umbraco v6.1.6 Installed Examine Ispector - great package
strange results
in examine inspector fudge the query and try
[000000 TO 200000]
Does that return anything? Also can you show me how the fields are stored in umbraco with a picture from examine inspector.
Regards
Ismail
price:[000000 TO 200000] - empty result
I need to see how your fields are stored can you do a normal search in examine inspector and show me a screen grab of the fields then pick a record and click on it and show me a screen grab of how the fields are stored.
Regards
Isamil
http://screencast.com/t/inUQO3HEt - how fields stored
Alex,
Price is not in d6 you have 2300 it should be 002300 what about _price which is what you have in your gatheringnode data code. Try running the query in examine inspector but on that _price field. Also can you show me screen grab of __price field and how that is stored.
I have done price ranges on http://www.world-of-incentives.com/programme-ideas.aspx and i have the price stored as d6 and when i query i use d6 i DID NOT store my field as _price as i think any field with _ will not be tokenised.
regards
Ismail
is working on a reply...