Skip to content

Instantly share code, notes, and snippets.

Created December 17, 2013 20:15
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 anonymous/8011821 to your computer and use it in GitHub Desktop.
Save anonymous/8011821 to your computer and use it in GitHub Desktop.
Boost is being ignored when using custom analyzers
#!/bin/bash
curl -XPOST 'http://localhost:9200/testing/type1/' -d '{
"id" : "1",
"field1" : "This is a test that I am running",
"field2" : "Hello world"
}'
curl -XPOST 'http://localhost:9200/testing/type1/' -d '{
"id" : "2",
"field1" : "Hello world",
"field2" : "This is a test that I am running"
}'
curl "localhost:9200/testing/type1/_search?pretty=true" -d '
{
"query" : {
"query_string": {
"default_field": "_all",
"query": "test"
}
}
}'
RESULT:
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 3,
"successful" : 3,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 0.06780553,
"hits" : [ {
"_index" : "testing",
"_type" : "type1",
"_id" : "wc606PqtSjqXtS9-sfwmQA",
"_score" : 0.06780553, "_source" : {
"id" : "1",
"field1" : "This is a test that I am running",
"field2" : "Hello world"
}
}, {
"_index" : "testing",
"_type" : "type1",
"_id" : "iR_Y4RraTnKd4deTaMn7HQ",
"_score" : 0.06780553, "_source" : {
"id" : "2",
"field1" : "Hello world",
"field2" : "This is a test that I am running"
}
} ]
}
}
curl -XPUT localhost:9200/_template/test_template -d '
{
"template" : "test*",
"settings" : {
"index" : {
"number_of_shards" : 3,
"analysis" : {
"filter" : {
"simple_word_del_filter" : {
"type" : "word_delimiter",
"generate_word_parts" : false,
"generate_number_parts" : false,
"split_on_case_change" : false,
"preserve_original" : true,
"split_on_numerics" : false,
"stem_english_possessive" : false
},
"min_len_filter" : {
"type" : "length",
"min" : 2
}
},
"analyzer" : {
"aph_analyzer" : {
"filter" : ["lowercase", "simple_word_del_filter", "min_len_filter"],
"type" : "custom",
"tokenizer" : "whitespace",
"char_filter" : "html_strip"
},
"ws_lc_analyzer" : {
"tokenizer" : "whitespace",
"filter" : ["lowercase"]
}
}
}
}
},
"mappings" : {
"type1" : {
"_source" : {
"enabled" : true
},
"_all" : {
"enabled" : true,
"index_analyzer" : "aph_analyzer",
"search_analyzer" : "ws_lc_analyzer"
},
"properties" : {
"id" : {
"type" : "string",
"index" : "not_analyzed"
},
"field1" : {
"type" : "string",
"index" : "analyzed",
"index_analyzer" : "aph_analyzer",
"search_analyzer" : "ws_lc_analyzer",
"boost" : 10
},
"field2" : {
"type" : "string",
"index" : "analyzed",
"index_analyzer" : "aph_analyzer",
"search_analyzer" : "ws_lc_analyzer"
}
}
}
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment