sphawk
(sphawk)
January 13, 2023, 1:37pm
1
I'm trying to build a bool query.
{
"query": {
"bool" : {
"must" : [
{"term": { "language": "es_ES" }}
],
"should": [
{
"query_string": {
"query": "ejemplo",
"fields": ["title^100", "file^1000", "subtitle^50", "file^20", "meta^10", "text"]
}
}
]
}
}
}
this return
{
"took": 11,
"timed_out": false,
"_shards": {
"total": 69,
"successful": 69,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
in theory, all record without "language" equal to "es_ES" should be ignored, correct?
RabBit_BR
(andre.coelho)
January 13, 2023, 1:59pm
2
Hi @sphawk
Do you query filter all records with language = "es_ES" or ignore them?
sphawk
(sphawk)
January 13, 2023, 2:48pm
3
Hi @RabBit_BR
tnx for your answer.
I need all records with language = es_ES
RabBit_BR
(andre.coelho)
January 13, 2023, 3:02pm
4
In that case I would use Filter Query (and its benefits). I imagine language is keyword type.
{
"query": {
"bool": {
"filter": [
{
"term": {
"language": "es_ES"
}
}
],
"should": [
{
"query_string": {
"query": "ejemplo",
"fields": [
"title^100",
"file^1000",
"subtitle^50",
"file^20",
"meta^10",
"text"
]
}
}
]
}
}
}
sphawk
(sphawk)
January 13, 2023, 3:12pm
5
I've not defined the type... just created the bulk files like
{ "index" : { "_index" : "test", "_type" : "_doc", "_id" : "1935b0ba3b6fbe7045562a5a507b390a" } }
{"file":"example.pdf","external_link":"","date":"1991-07-16","date_approx":false,"title":"a title","subtitle":"","caption_it_IT":"{}",...,"language":"es_ES"}
and post using "http://127.0.0.1:9200/_bulk "
I think this is not the best method...
RabBit_BR
(andre.coelho)
January 13, 2023, 3:15pm
6
So, try like this:
{
"term": {
"language.keyword": "es_ES"
}
}
to check type Field Language try:
GET idx_name?filter_path=idx_name.mappings.properties.language
sphawk
(sphawk)
January 13, 2023, 3:21pm
7
awesome!
with language.keyword work perfectly.
thanks a lot @RabBit_BR
1 Like
system
(system)
Closed
February 10, 2023, 3:22pm
8
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.