Hi, Good Morning..
Below here is what I am trying to achieve...
I am trying to create an index 'dpa_suggestormultifield' in Elasticsearch with the below mappings for field 'Active_Substance_mstr'
PUT/ http://localhost:9200/dpa_suggestormultifield
{
"settings": {
"index": {
"number_of_shards": 1,
"analysis": {
"analyzer": {
"trigram": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase","shingle"]
}
},
"filter": {
"shingle": {
"type": "shingle",
"min_shingle_size": 2,
"max_shingle_size": 3
}
}
}
}
},
"mappings": {
"properties": {
"Active_Substance_mstr": {
"type": "text",
"fields": {
"trigram": {
"type": "text",
"analyzer": "trigram"
}
}
}
}
}
}
Below is the data I am inserting into my index.
POST/ http://localhost:9200/dpa_suggestormultifield/_bulk
{
"Active_Substance_mstr": "rurioctocog alfa pegol"
}
{
"Active_Substance_mstr": "tenofovir disoproxil"
}
{
"Active_Substance_mstr": "trastuzumad"
}
{
"Active_Substance_mstr": "CHLOROPROCAINE HYDROCHLORIDE"
}
{
"Active_Substance_mstr": "trastuzumad"
}
{
"Active_Substance_mstr": "The Vaccines and Related Biological Product"
}
{
"Active_Substance_mstr": "BGMQ2"
}
{
"Active_Substance_mstr": "Test"
}
{
"Active_Substance_mstr": "tar-ausguide20110608bio"
}
After data insert I am trying to get suggestions using phrase suggester with text 'prod' I didn't get matching results because of max_edits is defaluts to 2.
GET/ http://localhost:9200/dpa_suggestormultifield/_search
{
"suggest": {
"text" : "prod",
"simple_phrase" : {
"phrase" : {
"field" : "Active_Substance_mstr.trigram",
"size" : 1,
"direct_generator" : [ {
"field" : "Active_Substance_mstr.trigram",
"suggest_mode" : "always",
"min_word_length" : 1
} ]
}
}
}
}
However if I try to search with 'Produ' I get the results. Below is the response.
{
"took": 61,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 0,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"suggest": {
"simple_phrase": [
{
"text": "Produ",
"offset": 0,
"length": 5,
"options": [
{
"text": "product",
"score": 0.21575698
}
]
}
]
}
}
My question here is how to get results even if I search with 'prod' - I should get results as 'product' using phrase suggester
Please let me know if you need further details.