Skip to content

Instantly share code, notes, and snippets.

@nik9000
Created September 21, 2013 00:27
Show Gist options
  • Save nik9000/6645681 to your computer and use it in GitHub Desktop.
Save nik9000/6645681 to your computer and use it in GitHub Desktop.
fvh doesn't sort array entries by score but plain highlighter does
#!/bin/bash
curl -XDELETE "http://localhost:9200/test?pretty" -s
curl -XPOST "http://localhost:9200/test?pretty" -s
curl -XPOST "http://localhost:9200/test?pretty" -s
curl -XPUT http://localhost:9200/test/test/_mapping?pretty -d'{
"test" : {
"properties": {
"foo" : {
"type": "string",
"store": "yes",
"term_vector" : "with_positions_offsets"
}
}
}
}'
curl -XGET 'http://localhost:9200/_cluster/health?pretty=true&wait_for_status=yellow'
curl -XPOST "http://localhost:9200/test/test?pretty" -d '{"foo": ["great", "great highlighting"]}'
curl -XPOST "http://localhost:9200/test/_refresh?pretty" -s
curl -XPOST "http://localhost:9200/test/test/_search?pretty" -d '{
"query": {
"query_string": {
"fields": [ "foo" ],
"query": "great highlighting"
}
},
"highlight": {
"order": "score",
"fields": {
"foo": {
"number_of_fragments": 1,
"type": "fvh"
}
}
}
}'
# {
# "took" : 4,
# "timed_out" : false,
# "_shards" : {
# "total" : 5,
# "successful" : 5,
# "failed" : 0
# },
# "hits" : {
# "total" : 1,
# "max_score" : 0.26191524,
# "hits" : [ {
# "_index" : "test",
# "_type" : "test",
# "_id" : "dBHHrd3US02uVxTAKOFm2g",
# "_score" : 0.26191524, "_source" : {"foo": ["great", "great highlighting"]},
# "highlight" : {
# "foo" : [ "<em>great</em>" ]
# }
# } ]
# }
# }
curl -XPOST "http://localhost:9200/test/test/_search?pretty" -d '{
"query": {
"query_string": {
"fields": [ "foo" ],
"query": "great highlighting"
}
},
"highlight": {
"order": "score",
"fields": {
"foo": {
"number_of_fragments": 1,
"type": "plain"
}
}
}
}'
# {
# "took" : 3,
# "timed_out" : false,
# "_shards" : {
# "total" : 5,
# "successful" : 5,
# "failed" : 0
# },
# "hits" : {
# "total" : 1,
# "max_score" : 0.26191524,
# "hits" : [ {
# "_index" : "test",
# "_type" : "test",
# "_id" : "dBHHrd3US02uVxTAKOFm2g",
# "_score" : 0.26191524, "_source" : {"foo": ["great", "great highlighting"]},
# "highlight" : {
# "foo" : [ "<em>great</em> <em>highlighting</em>" ]
# }
# } ]
# }
# }
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment