I am trying to add autocomplete based on what the user searches.
Currently, I have the following mapping:
{
"courts_2": {
"mappings": {
"properties": {
"author": {
"type": "text",
"analyzer": "my_analyzer"
},
"bench": {
"type": "text",
"analyzer": "my_analyzer"
},
"citation": {
"type": "text"
},
"content": {
"type": "text",
"fields": {
"standard": {
"type": "text"
}
},
"analyzer": "my_analyzer"
},
"court": {
"type": "text"
},
"date": {
"type": "text"
},
"id_": {
"type": "text"
},
"title": {
"type": "text",
"fields": {
"standard": {
"type": "text"
}
},
"analyzer": "my_analyzer"
},
"verdict": {
"type": "text"
}
}
}
}
}
Below is the code I used for the settings:
{
"settings": {
"index": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "standard",
"filter": [
"lowercase",
"my_metaphone"
]
}
},
"filter": {
"my_metaphone": {
"type": "phonetic",
"encoder": "metaphone",
"replace": true
}
}
}
}
},
"mappings": {
"properties": {
"author": {
"type": "text",
"analyzer": "my_analyzer"
},
"bench": {
"type": "text",
"analyzer": "my_analyzer"
},
"citation": {
"type": "text"
},
"court": {
"type": "text"
},
"date": {
"type": "text"
},
"id_": {
"type": "text"
},
"verdict": {
"type": "text"
},
"title": {
"type": "text",
"analyzer": "my_analyzer",
"fields": {
"standard": {
"type": "text"
}
}
},
"content": {
"type": "text",
"analyzer": "my_analyzer",
"fields": {
"standard": {
"type": "text"
}
}
}
}
}
}
Here's what I would like to implement: I would like to collect and store all of the queries made to the endpoint and use autocomplete on that. For example, to date, all of the users have made the following queries -
Real Madrid v/s Barcelona
Real Madrid Team
Real Madrid Coach
Barcelona v/s Man City
Sevilla Home Ground
Man Utd. recent results
Now, if anyone searches Rea
then the following autocomplete queries should be suggested:
Real Madrid v/s Barcelona
Real Madrid Team
Real Madrid Coach
This based on the searches made by all of the users till date and not a single user. Further, I would like to analyze what are the top queries that were made in let's say the past month.
I am using ElasticSearch version 7.1 on AWS Elasticsearch service.