Solr 查询行为
我有一个包含食谱的 Solr 安装。
每个食谱都有多种成分,我目前正在构建一个食谱搜索,您可以输入“包含/排除”,然后我有一个在此之后出现的自制重量系统。
然而,查询构建尚未完成,因此需要改进。
// Works perfect - 109 results
ingredients:chicken OR tomatoes OR bacon
// Down to 7 results - Definitely wrong
ingredients:chicken OR tomatoes OR bacon AND -ingredients:garlic
我尝试过以任何方式构建此查询,但无法找出可接受的“模糊过滤器”
I have a Solr installation that contains recipes.
Each recipe has multiple ingredients and I'm currently building a recipe search that you can type 'includes/excludes' and then I have a homebrew weight system that comes in after this.
The query building is off however and so needs refining.
// Works perfect - 109 results
ingredients:chicken OR tomatoes OR bacon
// Down to 7 results - Definitely wrong
ingredients:chicken OR tomatoes OR bacon AND -ingredients:garlic
I've tried building this query any which way but can't figure out an acceptable 'fuzzy filter'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会这样做:
这对我有用。
您可以像这样添加所有排除项:
I would do:
This works for me.
You can add all excludes like this:
尝试
ingredients:鸡肉或西红柿或培根和(-ingredients:大蒜)
我假设您正在将Solr 3.1与
edismax
一起使用。我发现将否定查询括在括号中是有效的。我没有时间更详细地研究这个问题并弄清楚这是否是预期的行为还是一个错误。如果您更详细地调查此问题并确认这是一个错误,请在此处< /a>.
请注意,我上面建议的查询将根据您的配置在默认字段中搜索西红柿/培根。如果您只想在
ingredients
中搜索它们,请使用ingredients:(chicken ORmatoor OR bacon) AND (-ingredients:garlic)
Try
ingredients:chicken OR tomatoes OR bacon AND (-ingredients:garlic)
I am assuming that you are you are using Solr 3.1 with
edismax
.I have found that enclosing negative queries in parenthesis works. I have not had the time to look into this in more detail and figure out if this is the expected behaviour or is it a bug. If you investigate this in more detail and confirm that this is a bug, then please open a Jira issue here.
Note that the query I suggested above will search for tomatoes / bacon in the default field(s) as per your config. If you want to search for them in
ingredients
only, then useingredients:(chicken OR tomatoes OR bacon) AND (-ingredients:garlic)