简体   繁体   English

elasticsearch返回的faceface数

[英]elasticsearch number of facets returned

I have faceted queries working with elasticsearch 0.19.9. 我使用elasticsearch 0.19.9进行了多方面的查询。 However I would like to return all facets that have a count > 0. 但是我想返回计数> 0的所有方面。

According to the documentation I should be able to: 根据文档,我应该能够:

{
    "query" : {
        "match_all" : {  }
    },
    "facets" : {
        "tag" : {
            "terms" : {
                "field" : "tag",
                "all_terms" : true
            }
        }
    }

} }

As I understand, this should give me all facets even if count is 0. 据我所知,即使count为0,这也应该给我所有方面。

However, this is still only returning the top 10 facets by count. 然而,这仍然只是按计数返回前10个方面。 Which is the default size. 这是默认大小。 The only thing that seems to affect the number of returned facets is by actually setting "size" : N where N is the number of facets which will be returned. 唯一影响返回方面数的方法是实际设置"size" : N其中N是将返回的小平面数。

I could set this to a really high number but that just seems to hack-ish. 我可以将它设置为一个非常高的数字,但这似乎是黑客攻击。

Any ideas as to what I may be doing wrong? 关于我可能做错什么的任何想法?

You're not doing anything wrong. 你没有做错任何事。 You figured it out correctly! 你弄清楚了! There is an open issue on github to make the terms facet similar to the Terms Stats facet which allows you to set size=0 in order to get all the terms back. github上存在一个未解决的问题 ,使条款方面类似于条款统计方面 ,允许您设置size = 0以便获得所有条款。 For now you just need to use an high value, which is a bit tricky, I agree. 现在你只需要使用一个高值,这有点棘手,我同意。 On the other hand be careful not to return too many entries! 另一方面要注意不要返回太多条目!

{
    "query" : {
        "match_all" : {  }
    },
    "facets" : {
        "tag" : {
            "terms" : {
                "field" : "tag",
                "size" : 2147483647,
                "all_terms" : false
            }
        }
    }
}

The only way to remove the "count: 0" is to put "all_terms" as false, and set your size number as high and as impossible as you can in your Elasticsearch instance (the example above is the largest signed value that an integer in PHP can have). 删除“count:0”的唯一方法是将“all_terms”设置为false,并在Elasticsearch实例中将您的大小编号设置为高和不可能(上面的示例是一个整数的最大有符号值) PHP可以有)。

It may not be the best way, but this is the only known approach so far. 它可能不是最好的方法,但到目前为止这是唯一已知的方法。 Facet filter doesn't work with this at present (unless they updated and improved Elasticsearch to do it). Facet过滤器目前不适用于此(除非他们更新并改进了Elasticsearch来执行此操作)。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM