Skip to content

Instantly share code, notes, and snippets.

@Mpdreamz
Created January 23, 2014 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mpdreamz/8579620 to your computer and use it in GitHub Desktop.
Save Mpdreamz/8579620 to your computer and use it in GitHub Desktop.
Example of exact term boost over fuzzy for Tomas Jansson
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
{}
@Mpdreamz
Copy link
Author

Right now the search will first return 4, if you remove the term query from the should it will return 3 first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment