Skip to content

Instantly share code, notes, and snippets.

@ppearcy
Created October 12, 2011 00:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppearcy/1279879 to your computer and use it in GitHub Desktop.
Save ppearcy/1279879 to your computer and use it in GitHub Desktop.
ES synonym failure on 0.17.8
# Here are the contents of the synonym file that is located here: analysis/synonym_test.txt
test1, a+b
test2, b+c
test3, d/c
work, business
# Create the index
curl -XPOST localhost:9200/es-syntest -d '{
"settings" : {
"number_of_shards" : 1,
"analysis" : {"analyzer":{"synonym_test_analyzer":{"type":"custom","tokenizer":"standard","filter":["standard","lowercase","synonym_test","stop"]}},"filter":{"synonym_test":{"type":"synonym","synonyms_path":"analysis/synonym_test.txt","ignore_case":true,"expand":true}}}
},
"mappings" : {
"es-syntest" : {
"properties" : {
"attachmentcontent" : { "type" : "string", "omit_norms" : true, "include_in_all" : false, "analyzer" : "synonym_test_analyzer", "term_vector" : "with_positions_offsets"}
}
}
}
}'
# Add some docs
curl -XPUT 'http://localhost:9200/es-syntest/es-syntest/1' -d '{
"attachmentcontent" : "test1"
}'
curl -XPUT 'http://localhost:9200/es-syntest/es-syntest/2' -d '{
"attachmentcontent" : "test2"
}'
curl -XPUT 'http://localhost:9200/es-syntest/es-syntest/3' -d '{
"attachmentcontent" : "test3"
}'
curl -XPUT 'http://localhost:9200/es-syntest/es-syntest/4' -d '{
"attachmentcontent" : "a+b"
}'
curl -XPUT 'http://localhost:9200/es-syntest/es-syntest/5' -d '{
"attachmentcontent" : "b+c"
}'
curl -XPUT 'http://localhost:9200/es-syntest/es-syntest/6' -d '{
"attachmentcontent" : "d/c"
}'
curl -XPUT 'http://localhost:9200/es-syntest/es-syntest/7' -d '{
"attachmentcontent" : "work"
}'
curl -XPUT 'http://localhost:9200/es-syntest/es-syntest/8' -d '{
"attachmentcontent" : "business"
}'
# Run facet query
curl -XGET http://localhost:9200/es-syntest/es-syntest/_search?pretty=true -d '
{"query": {"match_all": {}}, "facets": {"tag": {"terms": {"field": "attachmentcontent", "size": 10000}}}, "size": 0}
'
# Results on 0.16.5
{
"took" : 68,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 8,
"max_score" : 1.0,
"hits" : [ ]
},
"facets" : {
"tag" : {
"_type" : "terms",
"missing" : 0,
"terms" : [ {
"term" : "work",
"count" : 2
}, {
"term" : "c",
"count" : 2
}, {
"term" : "busi",
"count" : 2
}, {
"term" : "b",
"count" : 2
}, {
"term" : "test3",
"count" : 1
}, {
"term" : "test2",
"count" : 1
}, {
"term" : "test1",
"count" : 1
}, {
"term" : "d/c",
"count" : 1
}, {
"term" : "d",
"count" : 1
}, {
"term" : "b+c",
"count" : 1
}, {
"term" : "a+b",
"count" : 1
} ]
}
}
}
# Results on 0.17.8
{
"took" : 20,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 8,
"max_score" : 1.0,
"hits" : [ ]
},
"facets" : {
"tag" : {
"_type" : "terms",
"missing" : 0,
"total" : 10,
"other" : 0,
"terms" : [ {
"term" : "c",
"count" : 2
}, {
"term" : "b",
"count" : 2
}, {
"term" : "work",
"count" : 1
}, {
"term" : "test3",
"count" : 1
}, {
"term" : "test2",
"count" : 1
}, {
"term" : "test1",
"count" : 1
}, {
"term" : "d",
"count" : 1
}, {
"term" : "busi",
"count" : 1
} ]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment