How to do partial matching on decimal numbers in a text field?


(Joe Crocker) #1

Does anyone know how to perform partial matching on a decimal number in string? How should my index and mappings be configured to accomplish this?

Using example data below, I would like to see the results for the following queries:
Query: "query": "1"
Search Results:
We are looking for C++ and C# developers 1.6
We are looking for C developers 1
We are looking for project managers 1.1

Query: "query": "1."
Search Results:
We are looking for C++ and C# developers 1.6
We are looking for project managers 1.1

Query: "query": ".1"
Search Results:
We are looking for project managers 1.1

----------------------- Example ---------------
PUT /my_index3
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"type": "custom",
"filter": [
"lowercase"
],
"tokenizer": "standard"
}
}
}
}
}

PUT /my_index3/_mapping/jobs
{
"properties": {
"content": {
"type": "string",
"analyzer": "my_analyzer"
}
}
}

POST /_bulk
{"index":{"_index":"my_index3","_type":"jobs"}}
{"content":"We are looking for C++ and C# developers 1.6"}
{"index":{"_index":"my_index3","_type":"jobs"}}
{"content":"We are looking for C developers 1"}
{"index":{"_index":"my_index3","_type":"jobs"}}
{"content":"We are looking for project managers 4.5"}
{"index":{"_index":"my_index3","_type":"jobs"}}
{"content":"We are looking for project managers 16.2"}
{"index":{"_index":"my_index3","_type":"jobs"}}
{"content":"We are looking for project managers 6"}
{"index":{"_index":"my_index3","_type":"jobs"}}
{"content":"We are looking for project managers 1.1"}
{"index":{"_index":"my_index3","_type":"jobs"}}
{"content":"We are looking for project managers fu boo"}

GET /my_index3/jobs/_search
{
"query": {
"match": {
"content": {
"query": "1"
}
}
}
}


(system) #2