Currently, I am only querying the "content" of a web page stored in elastic search for a keyword match. I would like to add the title to that equation. I am using the top code (under "MARRY THIS") and would like to somehow insert the bottom code ("WITH THIS") but can't seem to find an explanation on how to do so.
MARRY THIS
{
"query": {
"function_score": {
"query": {
"match": {
"content": "keyword"
}
},
"functions": [{
"field_value_factor": {
"field": "obls",
"factor": 0.5,
"modifier": "ln2p"
}
}]
}
},
"from": "0",
"size": "100"
}
WITH THIS
{
"multi_match" : {
"query": "keyword",
"fields": [ "title^3", "content" ]
}
}
Thanks in advance!
More Practice: Elasticsearch Multi Match Query – More Practice 1. Multi Match Query multi_match query allows us to search for a value across multiple fields. GET javasampleapproach/tutorial/_search { "query": { "multi_match" : { "query": "restapi", "fields": [ "title", "tags"] } } }
The way the multi_match query is executed internally depends on the type parameter, which can be set to: ( default) Finds documents which match any field, but uses the _score from the best field. See best_fields . Finds documents which match any field and combines the _score from each field. See most_fields .
The Practical Scoring Function Elasticsearch runs Lucene under the hood so by default it uses Lucene's Practical Scoring Function. This is a similarity model based on Term Frequency (tf) and Inverse Document Frequency (idf) that also uses the Vector Space Model (vsm) for multi-term queries.
Take the single best score plus tie_breaker multiplied by each of the scores from other matching fields/ groups The fuzziness parameter cannot be used with the cross_fields type. The bool_prefix type’s scoring behaves like most_fields, but using a match_bool_prefix query instead of a match query.
I figured it out after a lot of trial and error, it looks like this:
{
"query": {
"function_score": {
"query": {
"multi_match": {
"query": "baseball",
"fields": ["content", "title"]
}
},
"functions": [{
"field_value_factor": {
"field": "obls",
"factor": 0.5,
"modifier": "ln2p"
}
}]
}
},
"from": "10",
"size": "100"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With