I am trying to setup opensearch index for searching projects inside our database. The mapping looks like this
{
"properties": {
"name": {
"type": "search_as_you_type"
},
"countries": {
"type": "text"
}
}
}
My example data looks like this, consists of project name and countries that the project resides. In this example the project’s in Thailand and Laos.
{
"name": "DXPC comare",
"countries": ["TH", "LA"]
}
I have a synonym set up to convert the search text to synonym. These are the configuration in the analysis
block.
{
"analyzer": {
"country_analyzer": {
"tokenizer": "standard",
"filter": [
"lowercase",
"country_analyzer_filter"
]
},
},
"filter": {
"country_analyzer_filter": {
"type": "synonym",
"synonyms": [
"australia => AU",
"austria => AS",
"thailand => TH",
"lao => LA",
"madagascar => MG",
"united states of america, usa => US"
]
}
}
}
Now I can make the search works for the name thanks to the search_as_you_type
type. But I wanted to make the countries
tab behaves the same, meaning I wanted to make the search return the DPXC comare
project when I search for tha
, thai
, and thailand
. At the current time, the said project would only return when I search for thailand
only. How can I configure my server or change how I sync the data from postgres to achieve that? Thank you for the responses and please comment if you need more explanations.
I am running AWS Opensearch Serverless.