Configuración completa de índices, queries, agregaciones y ciclo de vida para Cultiva Docs — base de conocimiento B2B con 50.000+ artículos indexados.
| Campo | Tipo | Analizador / Detalle |
|---|---|---|
| titulo | text | kb_analyzer + autocomplete + keyword subfield |
| contenido | text | kb_analyzer, boost x1 |
| resumen | text | kb_analyzer, boost x2 |
| categoria | keyword | Facet + filter exact match |
| tags | keyword[] | Multi-value, facet |
| autor | keyword | Filter + agg |
| puntuacion | float | Boost signal, range filter |
| vistas | integer | Popularity signal |
| publicado_en | date | ISO-8601, date histogram agg |
| nivel | keyword | beginner / intermediate / advanced |
| activo | boolean | Filter context (cached) |
{ "settings": { "number_of_shards": 3, "number_of_replicas": 1, "analysis": { "analyzer": { "kb_analyzer": { "type": "custom", "tokenizer": "standard", "filter": [ "lowercase", "asciifolding", "mktg_synonyms", "spanish_stemmer" ] }, "autocomplete_analyzer": { "type": "custom", "tokenizer": "autocomplete_tok", "filter": ["lowercase"] } }, "tokenizer": { "autocomplete_tok": { "type": "edge_ngram", "min_gram": 2, "max_gram": 15 } }, "filter": { "mktg_synonyms": { "type": "synonym", "synonyms": [ "email,correo,newsletter", "SEO,posicionamiento,SERP", "ads,anuncios,publicidad", "conversión,conversion,CVR", "embudo,funnel,pipeline" ] }, "spanish_stemmer": { "type": "stemmer", "language": "spanish" } } } } }
{ "query": { "bool": { "must": { "multi_match": { "query": "estrategia email marketing", "fields": [ "titulo^4", "resumen^2", "contenido", "tags^3" ], "type": "best_fields", "fuzziness": "AUTO", "operator": "or" } }, "filter": [ {"term": {"activo": true}}, {"range": { "publicado_en": { "gte": "now-2y" }} } ], "should": [ {"range": { "puntuacion": { "gte": 4.0, "boost": 2.0 }}}, {"term": { "nivel": { "value": "intermediate", "boost": 1.5 }}} ] } }, "highlight": { "fields": { "titulo": {}, "contenido": { "fragment_size": 180, "number_of_fragments": 2 } } }, "sort": [ {"_score": "desc"}, {"puntuacion": "desc"} ], "size": 15 }
{ "policy": { "phases": { "hot": { "min_age": "0ms", "actions": { "rollover": { "max_age": "30d", "max_primary_shard_size": "50gb" }, "set_priority": {"priority": 100} } }, "warm": { "min_age": "30d", "actions": { "shrink": {"number_of_shards": 1}, "forcemerge": {"max_num_segments": 1} } }, "cold": { "min_age": "90d", "actions": { "searchable_snapshot": { "snapshot_repository": "s3-backups" } } }, "delete": { "min_age": "730d", "actions": {"delete": {}} } } } }
{ "script": { "lang": "mustache", "source": { "query": { "bool": { "must": { "multi_match": { "query": "{{query}}", "fields": [ "titulo^4","resumen^2","contenido" ], "fuzziness": "AUTO" } }, "filter": [ {"term": {"activo": true}}, {{#categoria}} {"term": { "categoria": "{{categoria}}" }}, {{/categoria}} {"range": { "puntuacion": { "gte": "{{min_rating}}{{^min_rating}}0{{/min_rating}}" } }} ] } }, "size": "{{size}}{{^size}}15{{/size}}" } } }
# Llamada con parámetros desde Node.js / curl curl -X POST "http://es:9200/kb_articles/_search/template" \ -H "Content-Type: application/json" \ -d '{ "id": "kb-search", "params": { "query": "automatizar email leads", "categoria": "Automatización", "min_rating": 4.0, "size": 10 } }'