lucene – Elasticsearch not searching terms with dash sporadically
Using elasticsearch 7.11.2 and 7.15.1
I created an index :
PUT http://localhost:9200/car
{
"mappings": {
"properties": {
"Owner": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"data": {
"properties": {
"Country": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
I insert a document :-
POST http://localhost:9200/car/_doc
{
"data": {
"Country": "USA"
},
"authority": "john-doe"
}
When I search using below terms query :-
POST http://localhost:9200/car/_search
{
"query": {
"bool": {
"must": [
{
"terms": {
"authority": [
"johndoe"
],
"boost": 1.0
}
}
],
"adjust_pure_negative": true,
"boost": 1.0
}
}
}
the results are 0. However, it sometimes gives me one hit. This is sporadic. Sometimes 0 and sometimes 1 for the created document (not on repeated search, but on repeated insert+search)
If i replace the value “john-doe” with “johndoe” then i always get a successful search hit.
Is this expected? Why is this sporadic?
Read more here: Source link