Closed max-moser closed 1 year ago
Digging a bit, seems that the mappings have some incompatibility. Most likely due to the autodetect of field type inside title
since the keyword
is inside a multi field:
"title": {
"dynamic": "true",
"properties": {
"en": {
"type": "search_as_you_type",
"doc_values": false,
"max_shingle_size": 3
},
"fr": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
The generated query is:
{
"query": {
"bool": {
"minimum_should_match": "0<1",
"filter": [{
"match_all": {}
}],
"must": [{
"multi_match": {
"query": "CERN",
"fields": ["name^100", "title.*^5"],
"type": "phrase_prefix"
}
}]
}
},
"sort": ["_score"],
"track_total_hits": true,
"from": 0,
"size": 25
}
Resulting in:
opensearchpy.exceptions.RequestError: RequestError(400, 'search_phase_execution_exception', 'failed to create query: Can only use phrase prefix queries on text fields - not on [title.fr.keyword] which is of type [keyword]')
I think this can be fixed using dynamic templates (on it)
After a bit more digging, there are two problems:
1- Some fields are autodetected. Easily fixed with the dynamic templates. 2- The query is not being properly built. It should be (this is the query being built for ES7)
"multi_match": {
"query": "CERN",
"fields": ["name^100", "title.*^5", "title.*._2gram", "title.*._3gram"],
"type": "bool_prefix"
}
This should be working tho, see query parser
Pushed a new commit to fix the mappings. Once records-resources is released, particularly this commit tests will pass. They do locally:
Thanks everyone for your help here! 🚀
There's still an issue going on with the suggestions for contrib vocabularies... The following errors only happen with OSv2, but neither OSv1 nor ES7:
Without the
?suggest=CERN
part, it works:In fact, it even works with
?suggest=
but no value: