Skip to content

Instantly share code, notes, and snippets.

@yehosef
Last active August 29, 2015 14:15
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 yehosef/eaf9584d4394198e4f4f to your computer and use it in GitHub Desktop.
Save yehosef/eaf9584d4394198e4f4f to your computer and use it in GitHub Desktop.
elasticsearch position_offset_gap on objects
DELETE /test
PUT /test
{
"mappings": {
"nospace": {
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"keywords": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
}
}
}
}
},
"space_field": {
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"keywords": {
"position_offset_gap": 100,
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
}
}
}
}
},
"space_subfield": {
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"keywords": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string",
"position_offset_gap": 100
}
}
}
}
}
}
}
POST /test/nospace
{
"id":"1",
"name": "Sample",
"keywords": [
{
"id":5,
"name": "my kitchen"
},
{
"id":6,
"name": "sink repair"
}
]
}
POST /test/space_field
{
"id":"1",
"name": "Sample",
"keywords": [
{
"id":5,
"name": "my kitchen"
},
{
"id":6,
"name": "sink repair"
}
]
}
POST /test/space_subfield
{
"id":"1",
"name": "Sample",
"keywords": [
{
"id":5,
"name": "my kitchen"
},
{
"id":6,
"name": "sink repair"
}
]
}
#returns result
GET /test/nospace/_search
{"query": {"match_phrase": { "keywords.name": "kitchen sink"}}}
#returns result
GET /test/space_field/_search
{"query": {"match_phrase": { "keywords.name": "kitchen sink"}}}
#does not return results
GET /test/space_subfield/_search
{"query": {"match_phrase": { "keywords.name": "kitchen sink"}}}
# return results
GET /test/space_subfield/_search
{"query": {"match_phrase": { "keywords.name": "sink repair"}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment