AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / coding / Perguntas / 77120685
Accepted
Dwai
Dwai
Asked: 2023-09-17 14:11:23 +0800 CST2023-09-17 14:11:23 +0800 CST 2023-09-17 14:11:23 +0800 CST

Consulta de pesquisa elástica não retornando respostas esperadas usando dsl no elástico 8.8.2

  • 772

Eu tenho duas consultas, duas selecionadas em um documento de índice. os "aplicativos" são um caminho aninhado em "candidato". Procuro entre o campo workexp, summary , mas os documentos contém o valor no Felds, ele não aparece na consulta 1 abaixo. Sempre aparece na resposta da consulta 2. consulta 1:

 {
    "nested": {
        "path": "applications",
        "query": {
            "bool": {
                "must": [
                    {
                        "simple_query_string": {
                            "default_operator": "and",
                            "fields": [
                                "applications.workexp"
                            ],
                            "query": "(Tableau) Or (Tableau) Or (Tableau workbooks)"
                        }
                    },
                    {
                        "simple_query_string": {
                            "default_operator": "and",
                            "fields": [
                                "applications.summary"
                            ],
                            "query": "(Tableau) Or (Tableau) Or (Tableau workbooks)"
                        }
                    },
                    {
                        "match": {
                            "applications.forreqid": {
                                "query": "FH-REQ-3"
                            }
                        }
                    }
                ]
            }
        }
    }
}

consulta 2

{
    "nested": {
        "path": "applications",
        "query": {
            "bool": {
                "must": [
                    {
                        "match": {
                            "applications.forreqid": {
                                "query": "FH-REQ-3"
                            }
                        }
                    }
                ],
                "must_not": [
                    {
                        "simple_query_string": {
                            "default_operator": "and",
                            "fields": [
                                "applications.workexp"
                            ],
                            "query": "(Tableau) Or (Tableau) Or (Tableau workbooks)"
                        }
                    },
                    {
                        "simple_query_string": {
                            "default_operator": "and",
                            "fields": [
                                "applications.summary"
                            ],
                            "query": "(Tableau) Or (Tableau) Or (Tableau workbooks)"
                        }
                    }
                ]
            }
        }
    }
}

O documento que espero receber na resposta

{
    createdby : [email protected], 
    applications : [
        {
        applnid : yy, 
        summary : top and Tableau Server.· Involved in dashboard test cases creation and execution, prepared the understanding and function/ process flow documents on various dashboards for the end users.· Created technical specifications document as well as functional documents in support of the user requirements.· Generate Tableau reports to analyze data from multiple data sources like Oracle, SQL Server, Excel, Flat Files, etc · Experienced in designing customized interactive dashboards in Tableau using Marks, Action, filters, parameter and calculations · Having experience in Tableau Desktop Creating Sets, Group, Sort, Parameter, Quick filters, Context Filters, Data blending, Joins and Calculations etc.Experience Details · Educational Detai,
        workexp : Procurement of billing the project and Project lead · The solution involves in creating dashboards and stories that depict different levels and stages.· The very first is a managerial dashboard to give quick overview of the Categories and their overview among different geographical areas, trends and comparisons using Map Charts, Pies, Stacked Bars, Scatter Plots etc.· The second one concentrates more on slicing and dicing the inventory and sales data using Dual Axis Charts, Various line charts, Waterfall charts etc.· The last one is a blend of Calculated Fields, Table Calculations and a bit of LODs to answer different types of the requirements of the client. Role : Tableau Developer Revenue Growth in % · Used Filters to know Department wise Sales and their Cost for Particular Periods and draft various charts using Show Me in Tableau Desktop.,
        education : null, 
        certtrainings : null, 
        gaps : null, 
        skilltags : null, 
        forreqid : FH-REQ-3, 
        uploadedbyuser : null
        }
    ]
}

Código de consulta abaixo -

Query workExQuery = SimpleQueryStringQuery.of(q -> q.query(finalQuery)
                    .fields(Arrays.asList("applications.workexp")).defaultOperator(Operator.And))._toQuery();
            queries.add(workExQuery);

            Query summaryQuery = SimpleQueryStringQuery.of(q -> q.query(finalQuery)
                    .fields(Arrays.asList("applications.summary")).defaultOperator(Operator.And))._toQuery();
            queries.add(summaryQuery);

Formação da consulta 2:

Query query = Query.of(q -> q.nested(p -> p.path("applications").query(b -> b.bool(bq -> bq.mustNot(queries)))));

Consulta Final esClient.search(s -> s.index("candidature").query(query), Someclass.class);

Formação da consulta 1:

Query query = Query.of(q -> q.nested(p -> p.path("applications").query(b -> b.bool(bq -> bq.must(queries)))));

Mapeamentos para o campo em java

@Field(type = FieldType.Keyword, name = "applnid")
    private String applnid;

    @Field(type = FieldType.Text, name = "summary")
    private String summary;

    @Field(type = FieldType.Text, name = "skills")
    private String skills;

    @Field(type = FieldType.Text, name = "employers")
    private String employers;

    @Field(type = FieldType.Integer, name = "totalexperienceinyears")
    private String totalexperienceinyears;

    @Field(type = FieldType.Text, name = "workexp")
    private String workexp;

    @Field(type = FieldType.Text, name = "education")
    private String education;

    @Field(type = FieldType.Text, name = "certtrainings")
    private String certtrainings;

    @Field(type = FieldType.Integer, name = "gaps")
    private String gaps;

    @Field(type = FieldType.Text, name = "skilltags")
    private String skilltags;
    
    @Field(type = FieldType.Keyword, name = "forreqid")
    private String forreqid;
    
    @Field(type = FieldType.Keyword, name = "uploadedbyuser")
    private String uploadedbyuser;

Mapeamentos da consulta curl elástica

{
    "candidature": {
        "aliases": {},
        "mappings": {
            "properties": {
                "_class": {
                    "type": "keyword",
                    "index": false,
                    "doc_values": false
                },
                "applications": {
                    "type": "nested",
                    "include_in_parent": true,
                    "properties": {
                        "_class": {
                            "type": "keyword",
                            "index": false,
                            "doc_values": false
                        },
                        "applnid": {
                            "type": "keyword"
                        },
                        "certtrainings": {
                            "type": "text"
                        },
                        "education": {
                            "type": "text"
                        },
                        "employers": {
                            "type": "text"
                        },
                        "forreqid": {
                            "type": "keyword"
                        },
                        "gaps": {
                            "type": "integer"
                        },
                        "skills": {
                            "type": "text"
                        },
                        "skilltags": {
                            "type": "text"
                        },
                        "summary": {
                            "type": "text"
                        },
                        "totalexperienceinyears": {
                            "type": "integer"
                        },
                        "uploadedbyuser": {
                            "type": "keyword"
                        },
                        "workexp": {
                            "type": "text"
                        }
                    }
                },
                "candidateId": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },
                "contactnumber": {
                    "type": "keyword"
                },
                "createdby": {
                    "type": "keyword"
                },
                "email": {
                    "type": "keyword"
                },
                "fororg": {
                    "type": "keyword"
                },
                "name": {
                    "type": "text"
                }
            }
        },
        "settings": {
            "index": {
                "routing": {
                    "allocation": {
                        "include": {
                            "_tier_preference": "data_content"
                        }
                    }
                },
                "refresh_interval": "1s",
                "number_of_shards": "1",
                "provided_name": "candidature",
                "creation_date": "1694872335334",
                "store": {
                    "type": "fs"
                },
                "number_of_replicas": "1",
                "uuid": "9cRKu-TLRsGfwuKn2UTbWg",
                "version": {
                    "created": "8080299"
                }
            }
        }
    }
}
elasticsearch
  • 1 1 respostas
  • 35 Views

1 respostas

  • Voted
  1. Best Answer
    imotov
    2023-09-18T01:09:12+08:002023-09-18T01:09:12+08:00

    Na consulta simple_query_string Oré tratada apenas como uma palavra. Portanto, sua consulta é basicamente equivalente a pesquisar "Tableau" AND "OR" AND "workbooks"na consulta query_string. Nenhum dos campos contém a palavra Ore, como resultado, você não recebe nada.

    Se sua expectativa era que Orsua consulta funcionasse como um operador booleano, você precisa substituí-lo por |. Em outras palavras, sua consulta deve se tornar

    (Tableau) | (Tableau) | (Tableau workbooks)

    Consulte Sintaxe de consulta simples para obter mais informações.

    • 1

relate perguntas

  • Como compor uma consulta JSON confusa e desleixada para a API REST do Elasticsearch do Art Institute of Chicago

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    destaque o código em HTML usando <font color="#xxx">

    • 2 respostas
  • Marko Smith

    Por que a resolução de sobrecarga prefere std::nullptr_t a uma classe ao passar {}?

    • 1 respostas
  • Marko Smith

    Você pode usar uma lista de inicialização com chaves como argumento de modelo (padrão)?

    • 2 respostas
  • Marko Smith

    Por que as compreensões de lista criam uma função internamente?

    • 1 respostas
  • Marko Smith

    Estou tentando fazer o jogo pacman usando apenas o módulo Turtle Random e Math

    • 1 respostas
  • Marko Smith

    java.lang.NoSuchMethodError: 'void org.openqa.selenium.remote.http.ClientConfig.<init>(java.net.URI, java.time.Duration, java.time.Duratio

    • 3 respostas
  • Marko Smith

    Por que 'char -> int' é promoção, mas 'char -> short' é conversão (mas não promoção)?

    • 4 respostas
  • Marko Smith

    Por que o construtor de uma variável global não é chamado em uma biblioteca?

    • 1 respostas
  • Marko Smith

    Comportamento inconsistente de std::common_reference_with em tuplas. Qual é correto?

    • 1 respostas
  • Marko Smith

    Somente operações bit a bit para std::byte em C++ 17?

    • 1 respostas
  • Martin Hope
    fbrereto Por que a resolução de sobrecarga prefere std::nullptr_t a uma classe ao passar {}? 2023-12-21 00:31:04 +0800 CST
  • Martin Hope
    比尔盖子 Você pode usar uma lista de inicialização com chaves como argumento de modelo (padrão)? 2023-12-17 10:02:06 +0800 CST
  • Martin Hope
    Amir reza Riahi Por que as compreensões de lista criam uma função internamente? 2023-11-16 20:53:19 +0800 CST
  • Martin Hope
    Michael A formato fmt %H:%M:%S sem decimais 2023-11-11 01:13:05 +0800 CST
  • Martin Hope
    God I Hate Python std::views::filter do C++20 não filtrando a visualização corretamente 2023-08-27 18:40:35 +0800 CST
  • Martin Hope
    LiDa Cute Por que 'char -> int' é promoção, mas 'char -> short' é conversão (mas não promoção)? 2023-08-24 20:46:59 +0800 CST
  • Martin Hope
    jabaa Por que o construtor de uma variável global não é chamado em uma biblioteca? 2023-08-18 07:15:20 +0800 CST
  • Martin Hope
    Panagiotis Syskakis Comportamento inconsistente de std::common_reference_with em tuplas. Qual é correto? 2023-08-17 21:24:06 +0800 CST
  • Martin Hope
    Alex Guteniev Por que os compiladores perdem a vetorização aqui? 2023-08-17 18:58:07 +0800 CST
  • Martin Hope
    wimalopaan Somente operações bit a bit para std::byte em C++ 17? 2023-08-17 17:13:58 +0800 CST

Hot tag

python javascript c++ c# java typescript sql reactjs html

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve