Reputation: 1285
I have a JSON document which resembles this
{"type":"line","line_id":89522,"play_name":"Taming of the Shrew","speech_number":19,"line_number":"2.1.58","speaker":"PETRUCHIO","text_entry":"To instruct her fully in those sciences,"}
{"index":{"_index":"shakespeare","_id":89522}}
{"type":"line","line_id":89523,"play_name":"Taming of the Shrew","speech_number":19,"line_number":"2.1.59","speaker":"PETRUCHIO","text_entry":"Whereof I know she is not ignorant:"}
{"index":{"_index":"shakespeare","_id":89523}}
{"type":"line","line_id":89524,"play_name":"Taming Day","speech_number":19,"line_number":"2.1.60","speaker":"PETRUCHIO","text_entry":"Accept of him, or else you do me wrong:"}
{"index":{"_index":"shakespeare","_id":89524}}
I am trying to do a search on play_name that it will return as long as play_name contains "Taming".
My query is like this
GET /shakespeare/doc/_search
{
"query":{
"match":{"play_name":"Taming"}
}
}
HOwever, the things is that it doesnt return all the results where the play_name contains Taming. I read the docs and it seems this should work. Hence can anyone tell mw what I am doing wrong?
PS :this is my mapping settings
{
"shakespeare": {
"mappings": {
"doc": {
"properties": {
"line_id": {
"type": "integer"
},
"line_number": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"play_name": {
"type": "keyword"
},
"speaker": {
"type": "keyword"
},
"speech_number": {
"type": "integer"
},
"text_entry": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
Upvotes: 1
Views: 62
Reputation: 755
You should change the mapping for the play_name
field to "type": "text"
. You can still include a keyword mapping if you plan on searching for exact matches.
The final mapping for play_name
should look something like this:
"play_name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
Upvotes: 0
Reputation: 2555
EDIT
Try like this:
"query": {
"wildcard" : {
"play_name":"*Taming*"
}
}
Upvotes: 1