开发者

Lucene Tag Searching problems with C#, escape problems?

I am using lucene 2.9.2 (.NET doesnt have a lucene 3)

"tag:C#" Gets me the same results as "tag:c". How do i allow 'C#' to be a searchword? i tried changing Field.Index.ANALYZED to Field.Index.NOT_ANALYZED but that gave me no results.

I assumin开发者_如何学运维g i need to escape each tag, how might i do that?


The problem isn't the query, its the query analyzer you are using which is removing the "#" from both the query and (if you are using the same analyzer for insertion - which you should be) and the field.

You will need to find an analyzer that preserves special characters like that or write a custom one.

Edit: Check out KeywordAnalyzer - it might just do the trick:

"Tokenizes" the entire stream as a single token. This is useful for data like zip codes, ids, and some product names.


According to the Java Documentation for Lucene 2.9.2 '#' is not a special character, which needs escaping in the Query. Can you check out (i.e. by opening the index with Luke), how the value 'C#' is actually stored in the index?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜