I am currently working on a project in which we decided to use Elasticsearch as a search engine for an ad site.
I currently have the following business rule:
List 25 ads per page. Of these 25, 10 advertisements should be βPaid ads,β and the remaining 15 should be βFree.β All 25 should be relevant to the search being performed (i.e. Keywords, region, price, category, etc.).
I know I can do this using two separate queries, but that seems like a huge waste of resources. Is it possible to make "subqueries" (if you can name them?) And combine these results into a single result set? For some reason, you get only 10 "Paid" ads and 15 "Free" from elasticsearch in one request? Assuming, of course, that there is enough advertising to make this requirement possible.
Thanks for any help!
to change . Just add my map information for clarity.
"properties": {
"advertText": {
"type": "string",
"boost": 2,
"store": true,
"analyzer": "snowball"
},
"canonical": {
"type": "string",
"store": true
},
"category": {
"properties": {
"id": {
"type": "string",
"store": true
},
"name": {
"type": "string",
"store": true
},
"parentCategory": {
"type": "string",
"store": true
}
}
},
"contactNumber": {
"type": "string",
"index": "not_analyzed",
"store": true
},
"emailAddress": {
"type": "string",
"store": true,
"analyzer": "url_email_analyzer"
},
"advertType": {
"type": "string",
"index": "not_analyzed"
},
...
}
Then I want to be able to query this and get 10 results where "advertType": "Paid" and 15 where "advertType": "Free" ...