I want to create a query that will find by part of word any document in elastic (no matter in what field).
My template:
PUT _template/portal-smm-provider
{
"index_patterns": "portal-smm-provider",
"settings": { "number_of_shards": 5,
"analysis": {
"normalizer": {
"useLowercase": {
"type": "custom",
"filter": [ "lowercase" ]
}
}
} },
"mappings": {
"portal-smm-provider": {
"properties": {
"id": {"normalizer":"useLowercase", "type": "keyword"},
"rnk": {"type": "keyword", "copy_to": "full_provider"},
"mfo": {"type": "keyword", "copy_to": "full_provider"},
"edrpoy": {"normalizer":"useLowercase", "type": "keyword", "copy_to": "full_provider"},
"name": {"normalizer":"useLowercase", "type": "keyword", "copy_to": "full_provider"},
"divisionName": {"normalizer":"useLowercase", "type": "keyword"},
"status": {"type": "integer"},
"profileNumber": {"normalizer":"useLowercase", "type": "keyword", "copy_to": "full_provider"},
"profileDate": {"type": "date"},
"archiveUrl": {"normalizer":"useLowercase", "type": "keyword"},
"version": {"type": "long"},
"services": {
"type": "nested",
"properties": {
"serviceCode": {
"type": "keyword", "copy_to": "full_provider"
},
"mfo": {
"type": "keyword", "copy_to": "full_provider"
},
"accountNumber": {
"type": "keyword", "copy_to": "full_provider"
},
"commission": { "normalizer":"useLowercase",
"type": "keyword"
}
}
},
"users": {
"type": "nested",
"properties": {
"phone": {"type": "keyword"
},
"hashPwd": {"type": "text"}
}
},
"full_provider": {"type": "text"}
}
}
}
}
Here is my 2 documents:
PUT portal-smm-provider/portal-smm-provider/1554984asdf
{
"id": "1554984asdf",
"rnk": null,
"mfo": null,
"edrpoy": "310262",
"name": "Укр газ-трач",
"divisionName": null,
"status": null,
"profileNumber": null,
"profileDate": null,
"archiveUrl": null,
"services": [
{
"serviceCode": 18,
"mfo": 1214,
"accountNumber": 1,
"commission": null
}
],
"users": [
{
"phone": "+380965893696",
"hashPwd": "asdfasdf"
}
],
"version": 0
}
PUT portal-smm-provider/portal-smm-provider/1554984aaa
{
"id": "1554984aaa",
"rnk": null,
"mfo": null,
"edrpoy": "310262",
"name": "Укр газопостач",
"divisionName": null,
"status": null,
"profileNumber": null,
"profileDate": null,
"archiveUrl": null,
"services": [
{
"serviceCode": 18,
"mfo": 1214,
"accountNumber": 1,
"commission": null
}
],
"users": [
{
"phone": "+380965893696",
"hashPwd": "asdfasdf"
}
],
"version": 0
}
When I have such query:
{
"bool" : {
"filter" : [
{
"match_phrase_prefix" : {
"full_provider" : {
"query" : "газ-",
"slop" : 0,
"max_expansions" : 50,
"boost" : 1.0
}
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
it return both documents, but I want only document with name "Укр газ-трач" because it has hyphen "-" and another document doesn't.
What do I have to do? Maybe there is other query?