Hiya
I've indexed my docs with two 'keyword' fields:
- name (with index boost of 1.3)
- text
Also, the 'all' field is enabled.
Some of the docs have the name field filled in (in which case, this is
the most important field) and others not, in which case we just have the
keywords in the text field.
Here are four example results for a search on 'john smith', in
desecending order of relevance:

-
Name: John Smith
Text: John Smith passed away peacefully on March 20, aged 82.
Funeral service will be held on Tuesday, April 3 in .... -
Name: John Smith
Text: Passed away peacefully on March 20, aged 82. Funeral service
will be held on Tuesday, April 3 in ....
 -
Name: ''
Text: John Smith passed away peacefully on March 20, aged 82.
Funeral service will be held on Tuesday, April 3 in .... -
Name: Maggie Smith
Text: Maggie Smith passed away peacefully on March 20, aged 82.
Sadly missed by husband John
A naive search for 'john smith' on the 'all' field favours doc (4) over
doc (3).
I'm trying to apply this logic, in descending order of importance:
- all the words close together in the name field
- all the words close together in the text field, if the doc
doesn't have a name field - as many words as possible in the 'all' field
Does this query achieve that? Any way of improving it?
curl -XGET 'http://127.0.0.0:9200/ia_object/notice/_search?searchType=dfs_query_then_fetch' -d '
{
"sort" : [
"score"
],
"fields" : [],
"query" : {
"filteredQuery" : {
"filter" : {
"bool" : {
"must" : [
{
"term" : {
"status" : "active"
}
},
{
"term" : {
"location_id" : "23"
}
}
]
}
},
"query" : {
"disMax" : {
"tieBreaker" : "0.7",
"queries" : [
{
"queryString" : {
"fields" : [
"name"
],
"boost" : "1.3",
"query" : ""john smith"~4"
}
},
{
"filteredQuery" : {
"filter" : {
"term" : {
"has_name" : "0"
}
},
"query" : {
"queryString" : {
"fields" : [
"text"
],
"boost" : "1.5",
"query" : ""john smith"~4"
}
}
}
},
{
"queryString" : {
"boost" : 1,
"query" : "john smith"
}
}
]
}
}
}
},
"from" : 0,
"size" : "100"
}
'
thanks
Clint
--
Web Announcements Limited is a company registered in England and Wales,
with company number 05608868, with registered address at 10 Arvon Road,
London, N5 1PR.