I'm trying to construct a query against my index that will use function_score
to boost records where fields have certain values. In Kibana Dev Tools, I have the following query that returns 3 hits as expected:
GET /myindex/_search
{
"query": {
"function_score": {
"query": {
"multi_match": {
"query": "somename",
"fields": ["licenseName", "businessName"]
}
}
}
}
}
But when I try to reproduce this with NEST
, no filtering happens, and it just returns all records in the index. To me this looks equivalent, but I must be missing something:
var byNameSearchResult = await _elasticClient.SearchAsync<MyModel>(sr => sr
.Index("myindex")
.Query(qcd => qcd
.FunctionScore(fsqd => fsqd
.Query(fsqcd => fsqcd
.MultiMatch(mmqd => mmqd
.Query(message.Name)
.Fields(fd => fd
.Field(f => f.LicenseName)
.Field(f => f.BusinessName)
)
)
)
)
)
);
ETA: here's the DebugInformation
output:
Valid NEST response built from a successful (200) low level call on POST: /myindex/_search?pretty=true&error_trace=true&typed_keys=true
# Audit trail of this API call:
- [1] HealthyResponse: Node: http://192.168.100.2:9200/ Took: 00:00:00.3650673
# Request:
{}
# Response:
{
"took" : 9,
"timed_out" : false,
"_shards" : {
"total" : 2,
"successful" : 2,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 10000,
"relation" : "gte"
},
"max_score" : 1.0,
"hits" : [
// 10 records here
]
}
}
# TCP states:
Established: 78
CloseWait: 14
TimeWait: 12
# ThreadPool statistics:
Worker:
Busy: 1
Free: 32766
Min: 8
Max: 32767
IOCP:
Busy: 1
Free: 999
Min: 8
Max: 1000
Any ideas on what I'm missing in the NEST
query that would make it function like the raw query in Dev Tools?
question from:
https://stackoverflow.com/questions/65839260/elasticsearch-nest-query-not-behaving-like-the-equivalent-query-in-kibana-dev-to 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…