Skip to content

Instantly share code, notes, and snippets.

@kwloafman
Created April 11, 2012 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kwloafman/2359644 to your computer and use it in GitHub Desktop.
Save kwloafman/2359644 to your computer and use it in GitHub Desktop.
Stop Words in Quoted vs Unquoted Search
{"ok":true,"acknowledged":true}
{"ok":true,"acknowledged":true}
{"ok":true,"acknowledged":true}
{"ok":true,"_index":"test","_type":"test","_id":"1","_version":1}
{"ok":true,"_index":"test","_type":"test","_id":"2","_version":1}
{"ok":true,"_shards":{"total":4,"successful":3,"failed":0}}
{
"took" : 17,
"timed_out" : false,
"_shards" : {
"total" : 2,
"successful" : 2,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : null,
"hits" : [ {
"_index" : "test",
"_type" : "test",
"_id" : "1",
"_score" : null, "_source" :
{
"content" : "Acme Airlines is the worst way to travel."
},
"sort" : [ 0 ]
} ]
}
}
{
"took" : 6,
"timed_out" : false,
"_shards" : {
"total" : 2,
"successful" : 2,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
#!/bin/bash
curl -XDELETE localhost:9200/test/
echo
curl -XPUT localhost:9200/test/
echo
curl -XPUT localhost:9200/test/test/_mapping -d '
{
"test" : {
"_boost" : {
"null_value" : 1.0
},
"_source" : {
"enabled" : true
},
"dynamic" : false,
"type" : "object",
"properties" : {
"content" : {
"index" : "analyzed",
"type" : "string"
},
"publish_datetime" : {
"omit_term_freq_and_positions" : true,
"omit_norms" : true,
"index" : "not_analyzed",
"format" : "dateOptionalTime",
"type" : "date"
}
}
}
}'
echo
curl -XPUT localhost:9200/test/test/1 -d '
{
"content" : "Acme Airlines is the worst way to travel."
}'
echo
curl -XPUT localhost:9200/test/test/2 -d '
{
"content" : "Acme Airlines is the best way to get there."
}'
echo
curl -XPOST localhost:9200/test/_refresh
echo
curl -XGET 'localhost:9200/test/test/_search?pretty=true' -d '
{"from": 0,
"query": {"filtered": {"filter": {"bool": {"must_not": [{"or": [{"term": {"applied_content_labels": 2}},
{"term": {"applied_content_labels": 3}}]}]}},
"query": {"query_string": {"default_operator": "AND",
"fields": ["actor_name",
"actor_id",
"title",
"content"],
"query": "\"worst way to travel\""}}}},
"size": 25,
"sort": [{"publish_datetime": {"order": "desc"}}]}'
echo
curl -XGET 'localhost:9200/test/test/_search?pretty=true' -d '
{"from": 0,
"query": {"filtered": {"filter": {"bool": {"must_not": [{"or": [{"term": {"applied_content_labels": 2}},
{"term": {"applied_content_labels": 3}}]}]}},
"query": {"query_string": {"default_operator": "AND",
"fields": ["actor_name",
"actor_id",
"title",
"content"],
"query": "worst way to travel"}}}},
"size": 25,
"sort": [{"publish_datetime": {"order": "desc"}}]}'
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment