Copied to clipboard

Flag this post as spam?

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


  • Rich Green 2246 posts 4006 karma points
    Sep 02, 2010 @ 19:55
    Rich Green
    0

    MultiNodePicker & Examine

    Hi,

    I’m trying to search the following property using the excellent MultiNodePicker, the new Beta allows the data to be stored in two ways:

    <attributePicker><![CDATA[1057,1058,1060]]></attributePicker>

    OR

    <attributePicker>
        <MultiNodePicker>
                <nodeId>1057</nodeId>  
            <nodeId>1058</nodeId>
                <nodeId>1060</nodeId>
        </MultiNodePicker>
     </attributePicker>

    How would I use Examine to return for example the nodes which match 1057 AND 1060?

    I have Examine set up and working but not sure which criteria to use to match this.

    Many thanks

    Rich

     

  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Sep 03, 2010 @ 11:28
  • Rich Green 2246 posts 4006 karma points
    Sep 06, 2010 @ 15:51
    Rich Green
    0

    Ok,

    I've got as far as adding this to the index 

    Field:
    __attributePicker   
    Text:
    ,1055,1056,1058,
    

    I added the extra commas as I did not want the possibility of 1055 to match 1055 & 11055.

    All I want to do now is something like the following:

     var criteria = ExamineManager.Instance
                    .SearchProviderCollection["DemoSearcher"]
                    .CreateSearchCriteria();
    
                var filter = criteria               
                    .Field("__attributePicker", ",1055,")
                    .And()
          .Field("__attributePicker", ",1058,")
          .Compile();
    

    However at this point I realised I've probably not approached this correctly and the above doesn't work.

    I'm completely new to Examine/Lucene so would appreciate it if someone point me in the right direction.

    Thanks

    Rich

     

     

     

  • Aaron Powell 1708 posts 3044 karma points c-trib
    Sep 07, 2010 @ 00:46
    Aaron Powell
    0

    Replace the commas with a space. This will (generally) cause Lucene to index each "number" separately and then you can search against them.

    (I say generally because some analyzers will ignore numbers, such as the Stop and Simple analyzers, but if you're not changing the analyzer from the default then you wont have a problem with them being ignored)

  • Rich Green 2246 posts 4006 karma points
    Sep 22, 2010 @ 09:46
    Rich Green
    0

    Thanks,

    Got as far as adding the id's to the index as separate entries using the GatheringNodeData event

    The last piece in the jigsaw is to be able to search "__attributePicker" for results that match both 1055 & 1058. It's here where I'm stuck as I don't know how to build up the examine search query.

    Many thanks

    Rich

  • Aaron Powell 1708 posts 3044 karma points c-trib
    Sep 22, 2010 @ 10:00
    Aaron Powell
    1

    You could use the GroupedOr statement, that'd be the easiest way to do the search:

    var criteria = ExamineManager.Instance
        .SearchProviderCollection["DemoSearcher"]
        .CreateSearchCriteria();
    
        var filter = criteria.GroupedOr(new[] { "__attributePicker", "__attriubtePicker" }, new[] { "1055", "1058" }).Compile();              
    
        //generates: (__attributePicker:1055 __attributePicker:1058)

    That will find all the ones which have either of the ID's, you can use GroupedAnd if you want to make it ones with just those IDs

  • Rich Green 2246 posts 4006 karma points
    Sep 22, 2010 @ 10:15
    Rich Green
    0

    Thanks Slace! Worked perfect :)

  • Rich Green 2246 posts 4006 karma points
    Oct 21, 2010 @ 09:56
    Rich Green
    0

    Next issue, how & when do I remove this indexes when either a node is deleted or a value is removed from the MNTP field?

    Rich

  • 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.

Please Sign in or register to post replies