正确删除ElasticSearch中的索引

时间:2015-06-23 17:19:46

标签: java elasticsearch

当我从数据库中删除一些数据弹性搜索"未更新"然后重新启动他们的服务以获取更改。但是我想要正确地删除数据。

我的代码正确删除了所有索引,但是当我进行搜索时,count = 0的结果显示为结果。我想删除并且不会出现在搜索中,怎么做?

我的代码

try {
            String formatValue = URLEncoder.encode(veiculo, "UTF-8");
            Request.Delete("http://" + PropertiesSingleton.getValue("es.host") + ":9200/oknok/base_gerenciada/_query?q=spec_veiculo:" + formatValue + "&default_operator=AND")
                    .useExpectContinue()
                    .version(HttpVersion.HTTP_1_1)
                    .execute().returnContent().asString();
        } catch (IOException e) {
            Log.error(this, "Erro ao remover do Elastic Search.", e);
        }

我的搜索过滤器

{"from": 0, "size": 0, "query":{"bool":{"must":[{"term":{"last":true}}]}}, "facets": {"filters": {"terms": {"field": "spec_veiculo.raw", "all_terms": true,"size" : 999999, "order": "term"}}}}

搜索结果

{"took":4,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":8375,"max_score":0.0,"hits":[]},"facets":{"filters":{"_type":"terms","missing":0,"total":8375,"other":0,"terms":[{"term":"Abril - Arquitetura & Construção","count":67},{"term":"Abril - Aventuras na História","count":67},{"term":"Abril - Bebe.com.br","count":67},{"term":"Abril - Boa Forma","count":67},{"term":"Abril - Bons Fluidos","count":67},{"term":"Abril - Capricho","count":67},{"term":"Abril - Casa Claudia","count":67},{"term":"Abril - Casa.com.br","count":67},{"term":"Abril - Claudia","count":67},{"term":"Abril - Contigo!","count":0},{"term":"Abril - Elle","count":67},{"term":"Abril - Estilo","count":67},{"term":"Abril - Exame","count":67},{"term":"Abril - Exame PME","count":67},{"term":"Abril - Gestão Escolar","count":67},{"term":"Abril - Guia Quatro Rodas","count":67},{"term":"Abril - Guia do Estudante","count":67},{"term":"Abril - Hotel Pro","count":67},{"term":"Abril - Info","count":67} (...)

1 个答案:

答案 0 :(得分:0)

使用match phrase尝试删除代码。

如果您已经知道要删除的id document ,请尝试使用文档ID删除。

Deleting a Document