Reputation: 6514
I've been trying out some term weighting with cloudsearch to improve the search results. Previously, if I had a search query like this:
q=(and (or 'JUN/2015' (prefix 'JUN/2015')))&q.parser=structured
...I would get back 4650 results. I've updated the queries to give increased relevance to a particular field by adding this to my queries:
q.options={fields:['name^2']}
...but now the same query from above returns no results.
Why is the term weighting affecting the query so that it would cause nothing to be returned?
Upvotes: 0
Views: 282
Reputation: 2681
The fields
option doesn't just control boosting, it controls which fields are searched. So by specifying q.options={fields:['name^2']}
, you're only searching the name
field, and you're necessarily going to get fewer results because it's a more restrictive search.
Form the docs: http://docs.aws.amazon.com/cloudsearch/latest/developerguide/weighting-fields.html
In addition to controlling field weights, the fields option defines the set of fields that are searched by default if you use the simple query parser or don't specify a field in part of a compound expression when using the structured query parser. For more information, see Search Request Parameters in the Search API Reference.
So, the way around this is to specify the other fields, either in your compound query or in the fields
option. A bit more from the docs on searching specific fields:
By default, all text and text-array fields are searched when you use the simple query parser. You can specify which fields you want to search by specifying the q.options parameter. For example, this query constrains the search to the title and description fields and boosts the importance of matches in the title field over matches in the description field.
q=star wars&q.options={fields: ['title^5','description']}
Upvotes: 1