SearchHelper.Search is returning inaccurate result

joey magboo asked on March 25, 2022 20:11

Hi,

I have a job portal with filter feature. the user can filter jobs by State Code(AR,AL,AZ, etc) The filter feature works fine but I notice that if the "IN" StateCode filter or "OR" statecode filter is selected, it's bringing in every job available. please see below SearchFor values. thank you.

SearchFor: "+( +state:\"AR\") +_culture:([en-us TO en-us] [invariantifieldivaluei TO invariantifieldivaluei])" >> this is working with no issues

SearchFor: "+( +state:\"IN\") +_culture:([en-us TO en-us] [invariantifieldivaluei TO invariantifieldivaluei])" >> job results is not accurate.

Recent Answers


Juraj Ondrus answered on March 28, 2022 07:52

Maybe "IN" is a reserved word in Lucene.Net. Anyway, although for the end user the "search" interface might be the same, you should distinguish between searching and filtering data. There is a difference how things work in the background.
I assume that the job postings is somehow definite set of data. So, you can simply filter the data and not search the data. In cases like this, or with the product catalog, it might be easier to filter data rather than searching (with certain level of random results). E.g. when the user is searching for "green shoes" you can do a simple data filtering and add appropriate SQL WHERE condition.

Filtering takes an existing full list, and removes items based on criteria that match/don't match. While Search takes a blank slate and adds to it based on criteria that match/don't match. And in some cases, this could be tricky and some unwanted items may fit the criteria.

If you are using portal engine, I would recommend considering re-designing this and use the data source + filter + listing web part approach.
If you are using MVC - I would use e.g. the DocumentQuery and/or MultiDocumentQuery methods, compose appropriate WHERE condtions and return just the pages/items which wit your conditions.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.