Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
Cómo construir una relación N-Gram en Elasticsearch

Soy nuevo en Elasticsearch y estoy buscando crear una aplicación Front-End que tenga una lista de proverbios. A medida que el usuario navega por estos proverbios, quiero que encuentre proverbios N-Gram relacionados o proverbios analíticos de Proverb DB. Por ejemplo, al hacer clic en

"Una olla vigilada nunca hierve" traería las siguientes sugerencias:

  • Sugerencia de 1 gramo: "Dos pis en una olla"

  • Sugerencia de 2 gramos: "Una olla vigilada sabe amarga"

  • Sugerencia analítica: "Demasiados cocineros echan a perder el caldo"

¿Hay alguna manera de hacerlo en ES, o necesito construir mi propia lógica?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

La sugerencia de 1 gramo sale de la caja y las sugerencias de 2 gramos se pueden lograr fácilmente con shingle .

Aquí hay un intento

 PUT test { "settings": { "analysis": { "analyzer": { "2-grams": { "type": "custom", "tokenizer": "standard", "filter": [ "lowercase", "shingles" ] } }, "filter": { "shingles": { "type": "shingle", "min_shingle_size": 2, "max_shingle_size": 2, "output_unigrams": false } } } }, "mappings": { "properties": { "text": { "type": "text", "analyzer": "standard", "fields": { "2gram": { "type": "text", "analyzer": "2-grams" } } } } } }

A continuación indexar algunos documentos:

 PUT test/_doc/1 { "text": "Two pees in a pot" } PUT test/_doc/2 { "text": "A Watched pot tastes bitter" }

Finalmente, puede buscar sugerencias de 1 gramo utilizando la siguiente consulta y obtendrá ambos documentos en la respuesta:

 POST test/_search { "query": { "match": { "text": "A watched pot never boils" } } }

También puede buscar sugerencias de 2 gramos utilizando la siguiente consulta y solo aparecerá el segundo documento:

 POST test/_search { "query": { "match": { "text.2gram": "A watched pot never boils" } } }

PD: Sin embargo, no estoy seguro de cómo funciona la sugerencia "analítica", no dude en proporcionar más información y lo actualizaré.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!