Slide 9
Slide 9 text
mix & match
curl -XGET http://localhost:9200/dba.stackexchange.com/question/_search -d '
{
"query": {
"custom_score": {
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{"multi_match": {"fields": ["title^10", "body"], "query": "mysql"}},
{
"has_child": {
"child_type": "answer",
"query": {"match": {"body": "nosql"}}
}
}
],
"must_not": [
{"multi_match": {"fields": ["title", "body"], "query": "nosql"}}
]
}
},
"filter": {
"range": {"creation_date": {"from": "2012-01-01"}}
}
}
},
"script": "(_score + 1) * doc[\"rating\"].value"
}
},
"fields": ["title", "rating", "creation_date"],
"highlight": {
"fields": {
"title": {"fragment_size" : 50},
"body": {"fragment_size" : 50}
}
},
"facets": {
"tags": {
"terms": {"field": "tags"}
},
"frequency": {
"date_histogram": {"field": "creation_date", "interval": "month"}
}
}
}'
Find questions that
• Were asked last year
• Contain “mysql” in
title or body
• Don't contain “nosql”
• Have answer that has
“nosql” in title or body
• Include question rating
into score calculation
• Highlight matches in
html
• Aggregate over time
and tags
• ….