Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 22, 2014 @ 12:38
    Alex Skrypnyk
    0

    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

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Mar 22, 2014 @ 20:37
    Jeroen Breuer
    0

    Hello,

    Have a look at the souce code of ezSearch. It's a search package which is very easy to use.

    Jeroen

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 24, 2014 @ 09:28
    Alex Skrypnyk
    0

    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.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 24, 2014 @ 10:09
    Ismail Mayat
    0

    Alex,

    Can you paste code and explanation of what you are trying todo and what is not working?

    Regards

    Ismail

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 24, 2014 @ 10:31
    Alex Skrypnyk
    0

    Its my controller:

            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());
    }
    
  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 24, 2014 @ 10:37
    Ismail Mayat
    0

    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

    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.

    Regards

    Ismail

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 24, 2014 @ 10:45
    Alex Skrypnyk
    0

    Umbraco v6.1.6 Installed Examine Ispector - great package

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 24, 2014 @ 11:01
    Alex Skrypnyk
    0

    strange results

    1. price:[0 TO 2000] - empty results(should be 2 items)
    2. price:[0 TO 3000] - empty results(should be 3 items)
    3. price:[30 TO 300] - 2 results with price 30 (should be 2 items)
    4. price:[0 TO 2300] - 1 result with price 2300 (should be 3 items)
  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 24, 2014 @ 11:04
    Ismail Mayat
    0

    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

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 24, 2014 @ 11:05
    Alex Skrypnyk
    0

    price:[000000 TO 200000] - empty result

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 24, 2014 @ 11:09
    Ismail Mayat
    0

    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

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 24, 2014 @ 11:32
    Alex Skrypnyk
    0

    http://screencast.com/t/inUQO3HEt - how fields stored

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 24, 2014 @ 11:40
    Ismail Mayat
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft