如何实现标签搜索?用lucene? [英] How do i implement tag searching? with lucene?

查看:20
本文介绍了如何实现标签搜索?用lucene?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有用过 lucene.上次我问(几个月前,也许一年)人们建议使用 lucene.如果我不应该使用 lucene 我应该使用什么?例如说有这样标记的项目

I havent used lucene. Last time i ask (many months ago, maybe a year) people suggested lucene. If i shouldnt use lucene what should i use? As am example say there are items tagged like this

  1. 苹果胡萝卜
  2. 苹果
  3. 胡萝卜
  4. 苹果香蕉

如果用户搜索苹果,我不在乎 1,2 和 4 是否有任何偏好.但是我看到很多论坛都这样做,我讨厌的是,当用户搜索苹果胡萝卜 2 和 3 时结果很高,而 1 很难即使它与我的搜索更接近也要找到.

if a user search apples i dont care if there is any preference from 1,2 and 4. However i seen many forums do this which i HATED is when a user search apple carrots 2 and 3 have high results while 1 is hard to find even though it matches my search more closely.

我还希望能够搜索胡萝卜-苹果,这只会让我得到 3.我不确定如果我搜索胡萝卜香蕉会发生什么,但无论如何只要标记为 2 和 3 结果的更多项目排名较低然后 1 当我搜索苹果胡萝卜时,我会很高兴.

Also i would like the ability to do search carrots -apples which will only get me 3. I am not sure what should happen if i search carrots banana but anyways as long as more items tagged with 2 and 3 results are lower ranking then 1 when i search apples carrots i'll be happy.

lucene 能做到这一点吗?我从哪里开始?我尝试查找它,当我看到很多课程时,我会看到有关文档、网页的教程,但是当我喜欢标记某些东西时,没有一个人清楚地知道该怎么做.如果不是 lucene 我应该用什么来标记?

Can lucene do this? and where do i start? I tried looking it up and when i do i see a lot of classes and i'll see tutorials talking about documents, webpages but none were clear about what to do when i like to tag something. If not lucene what should i use for tagging?

推荐答案

Lucene for .net 似乎已经成熟了.无需使用 Java 或 SOLR

Lucene for .net seems to be mature. No need to use Java or SOLR

Lucene 的标准查询语言允许同等排名的搜索词和否定

The Standard query language for Lucene allows equally ranked search terms and negation

因此,如果您的 Lucene 索引有一个字段标签",您的查询将是

So if your Lucene index had a field "tag" your query would be

tag:apple* OR tag: carrot*

这将为每个单词提供相同的排名,并为带有两个标签的文档提供更多的排名权重

Which would give equal ranking to each word, and more rank weighting to document with both tags

要否定标签,请使用此

tag:carrot* NOT tag:apple*

显示使用 Lucene 进行索引和查询的简单示例 这里

Simple example to show indexing and querying with Lucene here

这篇关于如何实现标签搜索?用lucene?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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