I searched alot on this and tried numerous combinations. But failed in all attempts :(.
Here is my problem: I created a jdbc-river in elastic search as below:
{
"type" : "jdbc",
"jdbc" : {
"driver" : "oracle.jdbc.driver.OracleDriver",
"url" : "jdbc:oracle:thin:@//ip:1521/db",
"user" : "user",
"password" : "pwd",
"sql" : "select f1, f2, f3 from table"
},
"index" : {
"index" : "subject2",
"type" : "name2",
"settings": {
"analysis": {
"analyzer": {
"my_analizer": {
"type": "custom",
"tokenizer": "my_pattern_tokenizer",
"filter": []
}
},
"tokenizer": {
"my_pattern_tokenizer": {
"type": "pattern",
"pattern": "$^"
}
},
"filter": []
}
}
},
"mappings":
{
"subject2":
{
"properties" : {
"f1" : {"index" : "not_analyzed", "store": "yes", "analyzer": "my_analizer", "search_analyzer": "keyword", "type": "string"},
"f2" : {"index" : "not_analyzed", "store": "yes", "analyzer": "my_analizer", "search_analyzer": "keyword", "type": "string"},
"f3" : {"index" : "not_analyzed", "store": "yes", "analyzer": "my_analizer", "search_analyzer": "keyword", "type": "string"}
}
}
}
}
I want to implement an auto-complete feature that matches the user entered value with the data in "f1" field say as of now but from the start.
Data in the f1 field is like
- "Hardin County ABC"
- "Country of XYZ"
- "County of Blah blah"
- "County of Blah second"
What is as per requirement is when user types "Coun" then result 2nd, 3rd and 4th should be returned by the elastic search and not the first. I read about "keyword" analyzer that makes the complete word to be token but I don't know not working in this case.
Also, if user types "County of B" then 3rd and 4th option should be returned by the elastic search.
Below is the format of my querying the result. Option 1
{"from":0,"size":10, "query":{ "field" : { "f1" : "count*" } } }
Option 2
{"from":0,"size":10, "query":{ "span_first" : {
"match" : {
"span_term" : { "COMPANY" : "hardin" }
},
"end" : 1
} } }
Please tell me what wrong I am doing here? Thanks in advance.