Solr 接近有序与无序 [英] Solr proximity ordered vs unordered

查看:35
本文介绍了Solr 接近有序与无序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Solr 中,您可以使用语法执行有序邻近搜索

In Solr you can perform an ordered proximity search using syntax

"word1 word2"~10

按顺序,我的意思是 word1 在文档中总是排在 word2 之前.我想知道是否有一种简单的方法来执行无序的邻近搜索,即.word1 和 word2 出现在 10 个单词之内,无论哪个先出现.

By ordered, I mean word1 will always come before word2 in the document. I would like to know if there is an easy way to perform an unordered proximity search, ie. word1 and word2 occur within 10 words of each other and it doesn't matter which comes first.

一种方法是:

"word1 word2"~10 OR "word2 word1"~10

上述方法可行,但如果可能的话,我正在寻找更简单的方法.

The above will work but I'm looking for something simpler, if possible.

推荐答案

Slop表示可以发生多少个单词换位.所以a b"将与b a"不同,因为允许的换位次数不同.

Slop means how many word transpositions can occur. So "a b" is going to be different than "b a" because a different number of transpositions are allowed.

  • a foo b 有位置 (a,1), (foo, 2), (b, 3).要匹配 (a,1),(b,2) 需要进行一次更改:(b,2) => (b,3)
  • 但是,要匹配 (b,1), (a,2),您需要 (a,2) => (a,1) 和 (b,1) => (b,3),总共三个位置的运动
  • a foo b has positions (a,1), (foo, 2), (b, 3). To match (a,1), (b,2) will require one change: (b,2) => (b,3)
  • However, to match (b,1), (a,2) you will need (a,2) => (a,1) and (b,1) => (b,3), for a total of three position movements

一般来说,如果 "a b"~n 匹配某个东西,那么 "b a"~(n+2) 也会匹配它.

In general, if "a b"~n matches something, then "b a"~(n+2) will match it too.

我想我从来没有给出答案.我看到两个选项:

I guess I never gave an answer. I see two options:

  1. 如果您想要 n 的斜率,请将其增加到 n+2
  2. 按照您的建议手动分离您的搜索

我认为 #2 可能更好,除非你的 slop 一开始就很大.

I think #2 is probably better, unless your slop is very large to begin with.

这篇关于Solr 接近有序与无序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆