Create an index
···
PUT /new_index
{
"mappings": {
"properties": {
"data": {
"type": "keyword"
},
"hash": {
"type": "integer"
},
"hash_mapping": {
"type": "keyword"
},
"task_id": {
"type": "keyword"
}
}
}
}
···
Insert data
···
POST /new_index/_doc
{
"data": "111 123 124 456 789",
"hash": 12345,
"hash_mapping": "Sample mapping value",
"task_id": "Task No. 1"
}
···
The table structure in Elasticsearch is as above.
Now it is necessary to set up a fuzzy search.
Examples:
- When searching for data "111 123 124 456 789", it can be found with a matching degree of 100%.
- When searching for data "111 123 124 456", it can be found with a matching degree of 100%.
- When searching for data "111 123 124 333 789", it can be found with a matching degree of 80%.
- When searching for data "222 123 124 333 789", it cannot be found with a matching degree of 60%.
Return the matching data when the matching degree is greater than or equal to 80%.