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
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.
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.
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..
Examine returning wrong results
Guys,
Having an issue with Examine returning incorrect results for a custom indexer.
ExamineSettings.config:
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:
My code for doing the search is:
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
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
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
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
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
Oops,
marked wrong answer there, should have been the last one. I'm sure that's obvious to most though..
is working on a reply...