Skip to content

Instantly share code, notes, and snippets.

@dilshancalcey
Created August 23, 2012 12:58
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 dilshancalcey/3436362 to your computer and use it in GitHub Desktop.
Save dilshancalcey/3436362 to your computer and use it in GitHub Desktop.
omit_norms on _all field
Create Index
curl -XPUT http://localhost:9200/tester/ -d '{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"test" : {
"properties" : {
"name" : { "type" : "string", "index" : "analyzed", "omit_norms" : true, "include_in_all" : true }
}
}
}
}'
Insert doc with long name
curl -XPUT http://localhost:9200/tester/test/1 -d '{
"name" : "This is the long name of james"
}'
Insert doc with short name
curl -XPUT http://localhost:9200/tester/test/2 -d '{
"name" : "james"
}'
Search within name field
curl -XGET http://localhost:9200/tester/test/_search?pretty=true -d '{
"query": {
"text" : {"name" : "james"}
}
}'
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 0.5945348,
"hits" : [ {
"_index" : "tester",
"_type" : "test",
"_id" : "1",
"_score" : 0.5945348, "_source" : {
"name" : "This is the long name of james"
}
}, {
"_index" : "tester",
"_type" : "test",
"_id" : "2",
"_score" : 0.5945348, "_source" : {
"name" : "james"
}
} ]
}
}
Search within _all field
curl -XGET http://localhost:9200/tester/test/_search?pretty=true -d '{
"query": {
"text" : {"_all" : "james"}
}
}'
{
"took" : 13,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 0.4203996,
"hits" : [ {
"_index" : "tester",
"_type" : "test",
"_id" : "2",
"_score" : 0.4203996, "_source" : {
"name" : "james"
}
}, {
"_index" : "tester",
"_type" : "test",
"_id" : "1",
"_score" : 0.15764984, "_source" : {
"name" : "This is the long name of james"
}
} ]
}
}
-----------------------------------------------------------------------
Update the mapping
curl -XPUT http://localhost:9200/tester/test/_mapping -d '{
"test" : {
"properties" : {
"name" : { "type" : "string", "index" : "analyzed", "omit_norms" : false, "include_in_all" : false }
}
}
}'
Gets the mapping
curl -XGET http://localhost:9200/tester/test/_mapping?pretty=true
{
"test" : {
"properties" : {
"name" : {
"include_in_all" : false,
"omit_norms" : true,
"type" : "string"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment