Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.