Skip to content

Instantly share code, notes, and snippets.

@Vineeth-Mohan
Created April 28, 2012 05:46
Show Gist options
  • Save Vineeth-Mohan/2516361 to your computer and use it in GitHub Desktop.
Save Vineeth-Mohan/2516361 to your computer and use it in GitHub Desktop.
vineeth@vineeth-XPS-L501X:~/elasticSearch$ curl -X POST "localhost:9200/mec/public?pretty" -d '{ "name" : "then the dinos came" }' ; echo
{
"ok" : true,
"_index" : "mec",
"_type" : "public",
"_id" : "AYkHdBqmTDmiuc0cv0xorg",
"_version" : 1
}
vineeth@vineeth-XPS-L501X:~/elasticSearch$ curl -X POST "localhost:9200/mec/public?pretty" -d '{ "name" : "then the stone age came" }' ; echo
{
"ok" : true,
"_index" : "mec",
"_type" : "public",
"_id" : "Tb6sLLvLT0yMaht3fLbxzg",
"_version" : 1
}
}vineeth@vineeth-XPS-L501X:~/elasticSearch$ cat custom_score.json
{
"query": {
"custom_score": {
"query": {
"query_string": {
"default_field": "name",
"query": "stone"
}
},
"script": "_score"
}
},
"highlight": {
"fields": {
"name": {}
}
}
}
QUERY WITH TYPE - NOTICE THAT HIGHLIGHT IS NOT PRODUCED
vineeth@vineeth-XPS-L501X:~/elasticSearch$ curl -X POST 'http://localhost:9200/mec/public/_search?pretty' -d @custom_score.json
{
"took" : 4,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.5,
"hits" : [ {
"_index" : "mec",
"_type" : "public",
"_id" : "Tb6sLLvLT0yMaht3fLbxzg",
"_score" : 0.5, "_source" : { "name" : "then the stone age came" }
} ]
}
}
QUERY WITHOUT TYPE - NOTICE THAT HIGHLIGHT IS PRODUCED
vineeth@vineeth-XPS-L501X:~/elasticSearch$ curl -X POST 'http://localhost:9200/mec/_search?pretty' -d @custom_score.json
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.5,
"hits" : [ {
"_index" : "mec",
"_type" : "public",
"_id" : "Tb6sLLvLT0yMaht3fLbxzg",
"_score" : 0.5, "_source" : { "name" : "then the stone age came" },
"highlight" : {
"name" : [ "then the <em>stone</em> age came" ]
}
} ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment