- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在努力思考 more like this 是如何产生的查询有效,我似乎遗漏了一些东西。我阅读了文档,但 ES 文档通常有点……缺乏。
目标是能够按词频限制结果,正如所尝试的那样 here .
所以我设置了一个简单的索引,包括用于调试的术语向量,然后添加了两个简单的文档。
DELETE /test_index
PUT /test_index
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"doc": {
"properties": {
"text": {
"type": "string",
"term_vector": "yes"
}
}
}
}
}
PUT /test_index/doc/1
{
"text": "apple, apple, apple, apple, apple"
}
PUT /test_index/doc/2
{
"text": "apple, apple"
}
当我查看术语向量时,我看到了我所期望的:
GET /test_index/doc/1/_termvector
...
{
"_index": "test_index",
"_type": "doc",
"_id": "1",
"_version": 1,
"found": true,
"term_vectors": {
"text": {
"field_statistics": {
"sum_doc_freq": 2,
"doc_count": 2,
"sum_ttf": 7
},
"terms": {
"apple": {
"term_freq": 5
}
}
}
}
}
GET /test_index/doc/2/_termvector
{
"_index": "test_index",
"_type": "doc",
"_id": "2",
"_version": 1,
"found": true,
"term_vectors": {
"text": {
"field_statistics": {
"sum_doc_freq": 2,
"doc_count": 2,
"sum_ttf": 7
},
"terms": {
"apple": {
"term_freq": 2
}
}
}
}
}
当我使用 "min_term_freq": 1
运行以下查询时,我得到了两个文档:
POST /test_index/_search
{
"query": {
"more_like_this": {
"fields": [
"text"
],
"like_text": "apple",
"min_term_freq": 1,
"percent_terms_to_match": 1,
"min_doc_freq": 1
}
}
}
...
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 0.5816214,
"hits": [
{
"_index": "test_index",
"_type": "doc",
"_id": "1",
"_score": 0.5816214,
"_source": {
"text": "apple, apple, apple, apple, apple"
}
},
{
"_index": "test_index",
"_type": "doc",
"_id": "2",
"_score": 0.5254995,
"_source": {
"text": "apple, apple"
}
}
]
}
}
但是如果我将 "min_term_freq"
增加到 2(或更多),我什么也得不到,尽管我希望两个文档都被返回:
POST /test_index/_search
{
"query": {
"more_like_this": {
"fields": [
"text"
],
"like_text": "apple",
"min_term_freq": 2,
"percent_terms_to_match": 1,
"min_doc_freq": 1
}
}
}
...
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
为什么?我错过了什么?
如果我想设置一个查询,只返回出现 5 次 "apple"
的文档,而不是出现 2 次的文档,有没有更好的方法?
为了方便起见,这里是代码:
http://sense.qbox.io/gist/341f9f77a6bd081debdcaa9e367f5a39be9359cc
最佳答案
最小术语频率和最小文档频率实际上在进行 MLT 之前应用于输入。这意味着由于您在输入文本中只出现了一次 apple,因此 apple 从未符合 MLT 的条件,因为最小词频设置为 2。如果您将输入更改为“apple apple”,如下所示,一切正常 -
POST /test_index/_search
{
"query": {
"more_like_this": {
"fields": [
"text"
],
"like_text": "apple apple",
"min_term_freq": 2,
"percent_terms_to_match": 1,
"min_doc_freq": 1
}
}
}
最小文档频率也是如此。 Apple 在至少 2 个文档中被发现,因此 min_doc_freq 高达 2 将有资格从输入文本应用到 MLT 操作。
关于Elasticsearch 更喜欢这个查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28308196/
我收到一个错误: prefer_const_literals_to_create_immutables 在这个小部件上: child: Column( children: [
您发现自己最常使用这两种替代方案中的哪一个,哪一个更“惯用”? f arg (obj.DoStuff()) f 参数 <| obj.DoStuff() 最佳答案 总的来说,我不知道哪个更惯用。 就我个
经过一些搜索和测试,我了解了以下有关 lambda 表达式的事实。 1)当我们写一个lambda表达式时,编译器会为它创建一个匿名函数对象,并将其作为函数对象的一个实例; 2)lambda表达式的
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 9 年前。 Improve
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我更喜欢 dplyr 包中的函数 (select)。我加载了一个依赖于屏蔽选择功能的 MASS 包的包。除了约定 dplyr::select() 之外,是否有其他方法更喜欢从 dplyr 包中选择?
这个问题已经有答案了: Do rvalue references to const have any use? (8 个回答) 已关闭 9 年前。 在什么情况下您会更喜欢 void fun(const
我刚刚开始在 python 中使用 libsvm 并进行了一些简单的分类。 问题是我正在构建一个人脸检测系统,并且我想要一个非常低的错误拒绝率。另一方面,支持向量机似乎针对相同的错误拒绝和错误接受进行
我正在使用 GCC's atomic builtins增加一个共享的 volatile int。我只想增加值,我不关心返回值。为此,我应该选择 fetch_and_add 还是 add_and_fet
我在使用 Table View Controller 时遇到 iOS 11 的大标题问题。 我已经在 viewDidLoad 中将 prefersLargeTitles 设置为 true: overr
可以肯定地说,如果我不想在我的容器中重复,并且我不关心元素位置,因为我只想遍历容器,那么我应该使用 unordered_set 而不是 vector? 最佳答案 Is it safe to say t
我已经实现了 iOS 11 功能 prefersLargeTitles,它运行良好。纵向模式按预期工作: 我了解大标题在横向模式下始终保持折叠(小)状态,这对我来说很好。问题是当我尝试更改为横向然后再
这个问题在这里已经有了答案: MySQL vs PostgreSQL? Which should I choose for my Django project? (11 个答案) 关闭 7 年前。
我读过这个answer最后写了以下内容: Anything that you can with volatile can be done with synchronized, but not vice
我正在阅读 Jon Skeet 的书。 (#4) 但有一件事(除其他外)引起了我的注意: 主题: bool 值? 他在表格中写道:(X,Y 是 bool 值?) X | Y |
这个问题在这里已经有了答案: 关闭 12 年前。 Possible Duplicate: c difference between malloc and calloc 在任何情况下您更喜欢 mall
我使用包装在 UINavigationController 中的 UITableView 实现了一个基本的 UIViewController。我将 prefersLargeTitles 设置为 tru
我有很多 image/webp 图片,希望浏览器为 Safari 提供后备 image/jpg。 出于某种原因,Chrome(以及所有其他浏览器)仍在使用 jpg 图像而不是 webp。
我对 React 比较陌生;如果这是一个非常幼稚的问题,我深表歉意。 browserHistory有哪些技术优势?使其优于 hashHistory ?例如,使用 History API 是否有重大的性
如果我需要一个 Web 服务来回传递一个复杂的对象,我是否有理由更喜欢 SOAP 而不是 REST?以下是可能的 SOAP 消息示例: Joe abc123
我是一名优秀的程序员,十分优秀!