Skip to content

Instantly share code, notes, and snippets.

@markharwood
Created September 2, 2019 16:48
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 markharwood/881a91f3b25a352fe3578c7f44ccde7a to your computer and use it in GitHub Desktop.
Save markharwood/881a91f3b25a352fe3578c7f44ccde7a to your computer and use it in GitHub Desktop.
Example encoding of multi-value annotated text
# Example multi-value annotated text
DELETE test1
PUT test
{
"settings": {
"number_of_shards": 1
},
"mappings": {
"properties":{
"text":{
"type":"annotated_text"
}
}
}
}
POST test/_doc/1
{
"text":"he had a meeting with the [President of Mexico](Andrés+Obrador&Mexico) today"
}
GET test/_search
{
"query": {
"span_near": {
"clauses": [
{
"span_or": {
"clauses": [
{
"span_term": {
"text": {
"value": "met"
}
}
},
{
"span_term": {
"text": {
"value": "meeting"
}
}
}
]
}
},
{
"span_term": {
"text": {
"value": "Andrés Obrador"
}
}
}
],
"slop": 3,
"in_order": false
}
},
"highlight": {
"fields": {
"text": {
"type": "annotated"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment