Applying match_phrase and filter
up vote
1
down vote
favorite
Worked on Elastic Search 6.4.2. I want to use match_pharse
to get the retrieve the results from my index. In the same way I need to apply the filter for that. Any solution for this. I tried the below query
{
"query": {
"bool": {
"should":
{
"match_phrase": {
"title": "bike riding"
}}
}
}}
But When I using match_pharse
I need to pass the fields in order to get the results. I am sharing my mapping and query that I need to be edited. Any help that I can use the match_phrase
for a query.
Mapping:
{
"mapping": {
"doc": {
"properties": {
"content": {
"type": "text",
"store": true,
"analyzer": "my_analyzer"
},
"description": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"domain": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"host": {
"type": "keyword",
"store": true
},
"keywords": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"seed": {
"type": "keyword",
"store": true
},
"title": {
"type": "text",
"store": true,
"analyzer": "my_analyzer"
},
"url": {
"type": "text",
"store": true
}
}
}
}
}`
Query:
How can I add match_phrase
to the below one
{
"query": {
"bool" : {
"must" : {
"query_string" : {
"query" : "bike riding"
}
},
"filter" : {
"term" : { "seed" : "sports" }
}
}
}
}
elasticsearch
add a comment |
up vote
1
down vote
favorite
Worked on Elastic Search 6.4.2. I want to use match_pharse
to get the retrieve the results from my index. In the same way I need to apply the filter for that. Any solution for this. I tried the below query
{
"query": {
"bool": {
"should":
{
"match_phrase": {
"title": "bike riding"
}}
}
}}
But When I using match_pharse
I need to pass the fields in order to get the results. I am sharing my mapping and query that I need to be edited. Any help that I can use the match_phrase
for a query.
Mapping:
{
"mapping": {
"doc": {
"properties": {
"content": {
"type": "text",
"store": true,
"analyzer": "my_analyzer"
},
"description": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"domain": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"host": {
"type": "keyword",
"store": true
},
"keywords": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"seed": {
"type": "keyword",
"store": true
},
"title": {
"type": "text",
"store": true,
"analyzer": "my_analyzer"
},
"url": {
"type": "text",
"store": true
}
}
}
}
}`
Query:
How can I add match_phrase
to the below one
{
"query": {
"bool" : {
"must" : {
"query_string" : {
"query" : "bike riding"
}
},
"filter" : {
"term" : { "seed" : "sports" }
}
}
}
}
elasticsearch
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Worked on Elastic Search 6.4.2. I want to use match_pharse
to get the retrieve the results from my index. In the same way I need to apply the filter for that. Any solution for this. I tried the below query
{
"query": {
"bool": {
"should":
{
"match_phrase": {
"title": "bike riding"
}}
}
}}
But When I using match_pharse
I need to pass the fields in order to get the results. I am sharing my mapping and query that I need to be edited. Any help that I can use the match_phrase
for a query.
Mapping:
{
"mapping": {
"doc": {
"properties": {
"content": {
"type": "text",
"store": true,
"analyzer": "my_analyzer"
},
"description": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"domain": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"host": {
"type": "keyword",
"store": true
},
"keywords": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"seed": {
"type": "keyword",
"store": true
},
"title": {
"type": "text",
"store": true,
"analyzer": "my_analyzer"
},
"url": {
"type": "text",
"store": true
}
}
}
}
}`
Query:
How can I add match_phrase
to the below one
{
"query": {
"bool" : {
"must" : {
"query_string" : {
"query" : "bike riding"
}
},
"filter" : {
"term" : { "seed" : "sports" }
}
}
}
}
elasticsearch
Worked on Elastic Search 6.4.2. I want to use match_pharse
to get the retrieve the results from my index. In the same way I need to apply the filter for that. Any solution for this. I tried the below query
{
"query": {
"bool": {
"should":
{
"match_phrase": {
"title": "bike riding"
}}
}
}}
But When I using match_pharse
I need to pass the fields in order to get the results. I am sharing my mapping and query that I need to be edited. Any help that I can use the match_phrase
for a query.
Mapping:
{
"mapping": {
"doc": {
"properties": {
"content": {
"type": "text",
"store": true,
"analyzer": "my_analyzer"
},
"description": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"domain": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"host": {
"type": "keyword",
"store": true
},
"keywords": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"seed": {
"type": "keyword",
"store": true
},
"title": {
"type": "text",
"store": true,
"analyzer": "my_analyzer"
},
"url": {
"type": "text",
"store": true
}
}
}
}
}`
Query:
How can I add match_phrase
to the below one
{
"query": {
"bool" : {
"must" : {
"query_string" : {
"query" : "bike riding"
}
},
"filter" : {
"term" : { "seed" : "sports" }
}
}
}
}
elasticsearch
elasticsearch
asked Nov 12 at 17:34
an__snatcher
488
488
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Below query is what you would be looking for.
Notice how I've added quotes around ""bike riding""
POST <your_index_name>/_search
{
"query": {
"bool" : {
"must" : {
"query_string" : {
"query" : ""bike riding""
}
},
"filter" : {
"term" : { "seed": "sports" }
}
}
}
}
Let me know if it helps!
Hi @Kamal, I tried your query Its gave null values and in filter I removed.keyword
for the field name that works exactly as I expected.
– an__snatcher
Nov 12 at 19:05
Yup yup, sorry about that :) Nevertheless, I'm glad it worked once you removed.keyword
.
– Kamal
Nov 12 at 19:08
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Below query is what you would be looking for.
Notice how I've added quotes around ""bike riding""
POST <your_index_name>/_search
{
"query": {
"bool" : {
"must" : {
"query_string" : {
"query" : ""bike riding""
}
},
"filter" : {
"term" : { "seed": "sports" }
}
}
}
}
Let me know if it helps!
Hi @Kamal, I tried your query Its gave null values and in filter I removed.keyword
for the field name that works exactly as I expected.
– an__snatcher
Nov 12 at 19:05
Yup yup, sorry about that :) Nevertheless, I'm glad it worked once you removed.keyword
.
– Kamal
Nov 12 at 19:08
add a comment |
up vote
1
down vote
accepted
Below query is what you would be looking for.
Notice how I've added quotes around ""bike riding""
POST <your_index_name>/_search
{
"query": {
"bool" : {
"must" : {
"query_string" : {
"query" : ""bike riding""
}
},
"filter" : {
"term" : { "seed": "sports" }
}
}
}
}
Let me know if it helps!
Hi @Kamal, I tried your query Its gave null values and in filter I removed.keyword
for the field name that works exactly as I expected.
– an__snatcher
Nov 12 at 19:05
Yup yup, sorry about that :) Nevertheless, I'm glad it worked once you removed.keyword
.
– Kamal
Nov 12 at 19:08
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Below query is what you would be looking for.
Notice how I've added quotes around ""bike riding""
POST <your_index_name>/_search
{
"query": {
"bool" : {
"must" : {
"query_string" : {
"query" : ""bike riding""
}
},
"filter" : {
"term" : { "seed": "sports" }
}
}
}
}
Let me know if it helps!
Below query is what you would be looking for.
Notice how I've added quotes around ""bike riding""
POST <your_index_name>/_search
{
"query": {
"bool" : {
"must" : {
"query_string" : {
"query" : ""bike riding""
}
},
"filter" : {
"term" : { "seed": "sports" }
}
}
}
}
Let me know if it helps!
edited Nov 12 at 19:04
an__snatcher
488
488
answered Nov 12 at 18:34
Kamal
1,154820
1,154820
Hi @Kamal, I tried your query Its gave null values and in filter I removed.keyword
for the field name that works exactly as I expected.
– an__snatcher
Nov 12 at 19:05
Yup yup, sorry about that :) Nevertheless, I'm glad it worked once you removed.keyword
.
– Kamal
Nov 12 at 19:08
add a comment |
Hi @Kamal, I tried your query Its gave null values and in filter I removed.keyword
for the field name that works exactly as I expected.
– an__snatcher
Nov 12 at 19:05
Yup yup, sorry about that :) Nevertheless, I'm glad it worked once you removed.keyword
.
– Kamal
Nov 12 at 19:08
Hi @Kamal, I tried your query Its gave null values and in filter I removed
.keyword
for the field name that works exactly as I expected.– an__snatcher
Nov 12 at 19:05
Hi @Kamal, I tried your query Its gave null values and in filter I removed
.keyword
for the field name that works exactly as I expected.– an__snatcher
Nov 12 at 19:05
Yup yup, sorry about that :) Nevertheless, I'm glad it worked once you removed
.keyword
.– Kamal
Nov 12 at 19:08
Yup yup, sorry about that :) Nevertheless, I'm glad it worked once you removed
.keyword
.– Kamal
Nov 12 at 19:08
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267300%2fapplying-match-phrase-and-filter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown