简体   繁体   English

在索引文档 elasticsearch 中搜索文本

[英]search a text in index documents elasticsearch

i'am trying to query elasticsearch index to retrieve only documents containing specific string(text) example "Mensuelle".我正在尝试查询 elasticsearch 索引以仅检索包含特定字符串(文本)示例“Mensuelle”的文档。 I am new to elasticsearch help me please.我是 elasticsearch 的新手,请帮帮我。

here is the query这是查询

GET index/_search { 
"size": 100,
"query": {
    "bool": {
        "must": [{
                "query_string": {
                    "query": "Mensuelle",
                    "fields": [],
                    "type": "best_fields",
                    "default_operator": "or",
                    "max_determinized_states": 10000,
                    "enable_position_increments": true,
                    "fuzziness": "AUTO",
                    "fuzzy_prefix_length": 0,
                    "fuzzy_max_expansions": 50,
                    "phrase_slop": 0,
                    "escape": false,
                    "auto_generate_synonyms_phrase_query": true,
                    "fuzzy_transpositions": true,
                    "boost": 1.0
                }
            }
        ],
        "adjust_pure_negative": true,
        "boost": 1.0
    }
}

} }

and here is an exmple of document {这是一个文档示例{

"_index": "sf147a",
"_type": "sf",
"_id": "sf147a_9b754d43a0e698a7b97319f386bbb301df45ae2b_measure",
"_score": 1,
"_source": {
    "Monnaie ": "M1B : Euros",
    "Activité ": "SB1 : France",
    "metric": "SCH_0020",
    "Objet de l'opération de crédit ": "SMA : Total résidence principale",
    "Période couverte ": "SPL : Dernier mois",
    "Tableau": "CREDITHAB",
    "Variante Tableau": "CREDITHAB",
    "Fréquence": "Mensuelle",
    "Code CIB": "39996",
    "dateDebutSerie": "2020-08-31",
    "dateFinSerie": "2020-08-31"

this is just a sample of the returned documents.it actually has more data * and here is a part of the index mapping这只是返回文档的一个示例。它实际上有更多数据 * 这里是索引映射的一部分

{
"sf147b": {
    "mappings": {
        "properties": {
            "Activité ": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Catégorie de population": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Code CIB": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Code Description du fait": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Code catégorie de population": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Date d'arrêté": {
                "type": "date"
            },
            "Description du fait": {
                "type": "text",
                "copy_to": ["all_muses"]
            },
            "Début de période": {
                "properties": {
                    "date": {
                        "type": "date"
                    },
                    "value": {
                        "type": "keyword"
                    }
                }
            },
            "Element SURFI": {
                "type": "text",
                "copy_to": ["all_muses"]
            },
            "Fréquence": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Localisation du bien ou, à défaut, de l'opération ": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Monnaie ": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Objet de l'opération de crédit ": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Période couverte ": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Raison sociale": {
                "type": "text",
                "copy_to": ["all_muses"]
            },
            "SIREN": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Tableau": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Taux d'apport personnel ": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Taux d'endettement des emprunteurs ": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Taxonomie": {
                "properties": {
                    "date": {
                        "type": "date"
                    },
                    "value": {
                        "type": "keyword"
                    }
                }
            },
            "Unité": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Variante Tableau": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "all_muses": {
                "type": "text",
                "analyzer": "muses1"
            },
            "dateDebutSerie": {
                "type": "date",
                "format": "yyyy-MM-dd"
            },
            "dateFinSerie": {
                "type": "date",
                "format": "yyyy-MM-dd"
            },
            "date_chargement_muses": {
                "type": "date"
            },
            "date_maj_serie": {
                "type": "date"
            },
            "decimals": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "faits": {
                "properties": {
                    "faitDate": {
                        "type": "date"
                    },
                    "faitMaj": {
                        "type": "date"
                    },
                    "faitValue": {
                        "type": "keyword"
                    }
                }
            },
            "famille": {
                "type": "keyword",
                "fields": {
                    "famille_a": {
                        "type": "text"
                    }
                },
                "copy_to": ["all_muses"]
            },
            "metric": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "serie_nulle": {
                "type": "text",
                "fields": {
                    "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                    }
                }
            },
            "sousFamille": {
                "type": "keyword",
                "fields": {
                    "sousFamille_a": {
                        "type": "text"
                    }
                },
                "copy_to": ["all_muses"]
            },
            "table_hbase": {
                "type": "keyword"
            },
            "tag_suggest": {
                "type": "completion",
                "analyzer": "muses1",
                "preserve_separators": false,
                "preserve_position_increments": false,
                "max_input_length": 40
            },
            "titreIndividu": {
                "type": "keyword"
            },
            "titreSerie": {
                "type": "keyword",
                "fields": {
                    "titreSerie_a": {
                        "type": "text"
                    }
                },
                "copy_to": ["all_muses"]
            }
        }
    }
}

} }

i'am trying to query elasticsearch index to retrieve only documents containing specific string(text) example "Mensuelle".我正在尝试查询 elasticsearch 索引以仅检索包含特定字符串(文本)示例“Mensuelle”的文档。 I am new to elasticsearch help me please.我是 elasticsearch 的新手,请帮帮我。

here is the query这是查询

GET index/_search { 
"size": 100,
"query": {
    "bool": {
        "must": [{
                "query_string": {
                    "query": "Mensuelle",
                    "fields": [],
                    "type": "best_fields",
                    "default_operator": "or",
                    "max_determinized_states": 10000,
                    "enable_position_increments": true,
                    "fuzziness": "AUTO",
                    "fuzzy_prefix_length": 0,
                    "fuzzy_max_expansions": 50,
                    "phrase_slop": 0,
                    "escape": false,
                    "auto_generate_synonyms_phrase_query": true,
                    "fuzzy_transpositions": true,
                    "boost": 1.0
                }
            }
        ],
        "adjust_pure_negative": true,
        "boost": 1.0
    }
}

} }

and here is an exmple of document {这是一个文档示例{

"_index": "sf147a",
"_type": "sf",
"_id": "sf147a_9b754d43a0e698a7b97319f386bbb301df45ae2b_measure",
"_score": 1,
"_source": {
    "Monnaie ": "M1B : Euros",
    "Activité ": "SB1 : France",
    "metric": "SCH_0020",
    "Objet de l'opération de crédit ": "SMA : Total résidence principale",
    "Période couverte ": "SPL : Dernier mois",
    "Tableau": "CREDITHAB",
    "Variante Tableau": "CREDITHAB",
    "Fréquence": "Mensuelle",
    "Code CIB": "39996",
    "dateDebutSerie": "2020-08-31",
    "dateFinSerie": "2020-08-31"

this is just a sample of the returned documents.it actually has more data * and here is a part of the index mapping这只是返回文档的一个示例。它实际上有更多数据 * 这里是索引映射的一部分

{
"sf147b": {
    "mappings": {
        "properties": {
            "Activité ": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Catégorie de population": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Code CIB": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Code Description du fait": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Code catégorie de population": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Date d'arrêté": {
                "type": "date"
            },
            "Description du fait": {
                "type": "text",
                "copy_to": ["all_muses"]
            },
            "Début de période": {
                "properties": {
                    "date": {
                        "type": "date"
                    },
                    "value": {
                        "type": "keyword"
                    }
                }
            },
            "Element SURFI": {
                "type": "text",
                "copy_to": ["all_muses"]
            },
            "Fréquence": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Localisation du bien ou, à défaut, de l'opération ": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Monnaie ": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Objet de l'opération de crédit ": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Période couverte ": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Raison sociale": {
                "type": "text",
                "copy_to": ["all_muses"]
            },
            "SIREN": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Tableau": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Taux d'apport personnel ": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Taux d'endettement des emprunteurs ": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Taxonomie": {
                "properties": {
                    "date": {
                        "type": "date"
                    },
                    "value": {
                        "type": "keyword"
                    }
                }
            },
            "Unité": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "Variante Tableau": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "all_muses": {
                "type": "text",
                "analyzer": "muses1"
            },
            "dateDebutSerie": {
                "type": "date",
                "format": "yyyy-MM-dd"
            },
            "dateFinSerie": {
                "type": "date",
                "format": "yyyy-MM-dd"
            },
            "date_chargement_muses": {
                "type": "date"
            },
            "date_maj_serie": {
                "type": "date"
            },
            "decimals": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "faits": {
                "properties": {
                    "faitDate": {
                        "type": "date"
                    },
                    "faitMaj": {
                        "type": "date"
                    },
                    "faitValue": {
                        "type": "keyword"
                    }
                }
            },
            "famille": {
                "type": "keyword",
                "fields": {
                    "famille_a": {
                        "type": "text"
                    }
                },
                "copy_to": ["all_muses"]
            },
            "metric": {
                "type": "keyword",
                "copy_to": ["all_muses"]
            },
            "serie_nulle": {
                "type": "text",
                "fields": {
                    "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                    }
                }
            },
            "sousFamille": {
                "type": "keyword",
                "fields": {
                    "sousFamille_a": {
                        "type": "text"
                    }
                },
                "copy_to": ["all_muses"]
            },
            "table_hbase": {
                "type": "keyword"
            },
            "tag_suggest": {
                "type": "completion",
                "analyzer": "muses1",
                "preserve_separators": false,
                "preserve_position_increments": false,
                "max_input_length": 40
            },
            "titreIndividu": {
                "type": "keyword"
            },
            "titreSerie": {
                "type": "keyword",
                "fields": {
                    "titreSerie_a": {
                        "type": "text"
                    }
                },
                "copy_to": ["all_muses"]
            }
        }
    }
}

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Elasticsearch:根据文本字段中搜索字符串的索引值对文档进行排序 - Elasticsearch: Sort the Documents on the index value of the search string in a text field 刷新索引之前的“ Elasticsearch”搜索文档 - “Elasticsearch” search documents before index refresh 如何上传/索引富文本/结构化文本文档以使用ElasticSearch进行搜索? - How do I upload/index rich/structured text documents to search with ElasticSearch? Elasticsearch:搜索具有大型文档(PDF,doc,txt)的索引的性能很慢 - Elasticsearch: Search Performance of index with large documents (PDF,doc,txt) is slow 带有大文档的Elasticsearch索引的搜索性能(PDF) - Search Performance of Elasticsearch index with large documents (PDF’s) 如何在Elasticsearch索引中搜索值为字段为空数组的文档? - How to search for documents in an elasticsearch index having value as empty array for a field? ElasticSearch带有文档的分面搜索 - ElasticSearch Faceted Search with Documents with it Elasticsearch-将文档添加到/ index1 / type2时,搜索index1 / type2文档分数发生变化 - Elasticsearch - search on index1/type2 document scores change when adding documents to /index1/type2 计算elasticsearch中索引中的文档数 - Counting number of documents in an index in elasticsearch Elasticsearch 从索引中删除文档 - Elasticsearch delete documents from index
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM