【问题标题】:More_like_this query only giving me 10 resultsMore_like_this 查询只给我 10 个结果
【发布时间】:2023-03-20 03:50:01
【问题描述】:

我正在使用 More like this 查询来获取医疗报告之间的相似性,然后将它们放入矩阵中。问题是不知何故它只给了我 10 个结果而不是全部。

我猜它给了我10个更相似的?

我们已尝试放置一个大小字段,但没有任何效果。

还有没有办法显示除以字段的结果?因为我读过它混合了所有领域的结果来给出最终分数,但我也想得到个别的结果

def search_similar (self, id_caso):
    return self._es_buscar(
        { 
            "size": 100, 
            "query": { 
                "more_like_this": {
                    "like": [ { "_id": id_caso} ],
                    "fields": self.conf.get('campos'),
                    "max_query_terms": 100,
                    "min_term_freq": 0,
                    "minimum_should_match": 0
                } 
            }    
        })

def _es_buscar (self, query):
    res = self._es.search(index="historiales",
                          doc_type="historial",
                          body=query)
    return [{ 'id': r['_id'], 'doc': r['_source'], 'score' : r['_score']} for r in res['hits']['hits']]

当我预期 32 个结果时,我只得到 10 个结果。我不明白为什么。

【问题讨论】:

    标签: python apache elasticsearch lucene morelikethis


    【解决方案1】:

    size 需要指定为 parameter to the search method,而不是在查询正文中:

    res = self._es.search(index="historiales",
                          doc_type="historial",
                          size=100,                      <--- add this
                          body=query)
    

    【讨论】:

      猜你喜欢
      • 2014-11-27
      • 1970-01-01
      • 1970-01-01
      • 2016-08-24
      • 2017-03-01
      • 2014-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多