Copied to clipboard

Flag this post as spam?

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


  • Mark 122 posts 255 karma points
    Jun 13, 2014 @ 17:21
    Mark
    0

    Examine returning wrong results

    Guys,

    Having an issue with Examine returning incorrect results for a custom indexer.

    ExamineSettings.config:

    <add name="ToolingIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine" 
    supportProtected="true" 
    analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" />
    <add name="ToolingSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
    analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" />

    I'm manually building a lucene search string for my page as using the api was not generating the right query so far as I can tell.

    A cut down version of my query with all bar two fields taken out ends up as:

    var basicToolingQuery = "+nodeTypeAlias:ProductDetail AND _trayLengthmm:[380 TO 420]";

    My code for doing the search is:

    var toolingSearcher = ExamineManager.Instance.SearchProviderCollection["ToolingSearcher"];
    
    var results = (Examine.LuceneEngine.SearchResults)toolingSearcher.Search(basicToolingQuery, false);
    

    This I expect to find all ProductDetail type nodes indexed with a tray length of between 380 and 420. Instead, what I get is just products returned that have a tray length of 420.

    I have been printing out the query on my screen so I can see what is being built and searched, and it comes out as above, and when I go to Examine Manager and search my index having copied and pasted that query, I get the correct results as expected. I even downloaded another plugin - "Examine Inspector" to see if that returned anything different, but that returns the correct results as expected too.

    Any ideas as to what the issue could be?

    One thing that I am having to do, is at the time of indexing, I am using the

    GatheringNodeData(object sender, IndexingNodeDataEventArgs e)

    event to add the fields that I am trying to read above (_trayLengthmm and a couple of similar other ones). This is because I am using CMS Import and am having to convert some decimals into ints in order for the range search to work correctly, as previously it was not returning any results. This means that in my ExamineIndex.config file, I am not setting the "Type" of these new fields to be "Number", though as I understand it, that shouldn't be an issue in any case.

    Any help here would be appreciated, it's probably something simple that I cannot see or haven't though of, but it's driving me up the wall, especially when my means of debugging (Examine Manager) is returning different results.

    Thanks in advance!

    Mark

  • Mark 122 posts 255 karma points
    Jun 16, 2014 @ 11:56
    Mark
    100

    Ok,

    I'm bumping this as I've still had no joy with it. I'm pretty certain it must be some kind of configuration issue as it's behaving consistently after rebuilding the index multiple times and re-importing all of my data.

    I have since tried adding padding around my numbers in case it was being treated as text, but had no joy there either.

    It would seem seem also that searching fields is not being restricted to the field in my query. For example a query of

    numberOfCavities:[16 TO 16]

    actually returns products where cavitlyLength == 16 as well even though their numberOfCavities field is say 8.

    If I need to give more info to help solve it, please just ask, but I am currently stumped and I really need to get this working quickly now. Not used Examine before now so wanderring partially sighted through all of this.

    Thank you :-)

    Mark

  • Mark 122 posts 255 karma points
    Jun 16, 2014 @ 16:41
    Mark
    0

    For anyone interested..

    It was in the end a padding issue, when building the index I had tried using .ToString("0").PadLeft(5,"0") to change my decimals into plain rounded numbers, which never worked. What I hadn't done is tried converting to an int and then using .ToString("D6") at the point of saving my fields. Then adding that into my search as well where I was querying the numerical field made it all just work.

    Knew it had to be something simple.. Lesson learned there..

    Mark

  • Mark 122 posts 255 karma points
    Jun 16, 2014 @ 16:42
    Mark
    0

    Oops,

    marked wrong answer there, should have been the last one. I'm sure that's obvious to most though..

Please Sign in or register to post replies

Write your reply to:

Draft