Created
January 23, 2014 14:44
-
-
Save Mpdreamz/8579620 to your computer and use it in GitHub Desktop.
Example of exact term boost over fuzzy for Tomas Jansson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PUT http://localhost:9200/prefix_test | |
{ | |
"settings": { | |
"blocks.read_only": false | |
}, | |
"settings": { | |
"analysis": { | |
"analyzer": { | |
"customanalyzer": { | |
"type": "custom", | |
"tokenizer": "uax_url_email", | |
"filters": [ | |
"lowercase" | |
] | |
} | |
} | |
} | |
}, | |
"mappings": { | |
"doc": { | |
"properties": { | |
"text": { | |
"type": "string", | |
"index_analyzer": "customanalyzer", | |
"search_analyzer": "customanalyzer" | |
} | |
} | |
} | |
} | |
} | |
POST http://localhost:9200/prefix_test/doc/1 | |
{ | |
"text": "testphone 5" | |
} | |
POST http://localhost:9200/prefix_test/doc/2 | |
{ | |
"text": "testphone 6" | |
} | |
POST http://localhost:9200/prefix_test/doc/3 | |
{ | |
"text": "testphone samsung" | |
} | |
POST http://localhost:9200/prefix_test/doc/4 | |
{ | |
"text": "testprone samsung" | |
} | |
POST http://localhost:9200/prefix_test/doc/_search | |
{ | |
"query" : { | |
"bool": { | |
"should": [ | |
{ | |
"term": { | |
"text": { | |
"value": "testprone" | |
} | |
} | |
}, | |
{ | |
"fuzzy": { | |
"text": { | |
"min_similarity": 0.4, | |
"value": "testprone", | |
"prefix_length": 0 | |
} | |
} | |
} | |
] | |
} | |
}, | |
"sort": [ | |
"_score" | |
], | |
"explain": true | |
} | |
DELETE http://localhost:9200/prefix_test | |
{} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right now the search will first return 4, if you remove the term query from the should it will return 3 first.