允许使用lucene.net搜索GUID [英] Enable to search GUID using lucene.net

查看:103
本文介绍了允许使用lucene.net搜索GUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用lucene.net(LUCENE_30),因为我想搜索GUID格式但不能通过使用lucene searchresult搜索的类别。



我们可以使用lucene搜索来搜索GUID吗?



我的代码看起来像这样,其中maxResult = 10000;



I am using lucene.net (LUCENE_30) in that I want to search categories which is in GUID format but not able to search that via using lucene searchresult.

Could we search GUID using lucene search?

My code look like this where maxResult = 10000;

QueryParser parser = new QueryParser(version, "IDTag", analyzer);
termQuery = parser.Parse(strIDTag);// where I am passing GUID value
TopDocs topDocs = searcher.Search(termQuery, maxResults);





在topDocs之后我得到零点击率。我可以使用什么类型的搜索查询,我使用了QueryParser,BooleanQuery,TermQuery。任何人都可以帮我这个吗?



After this in topDocs I am getting zero hits. What type of search query could I use, I have used QueryParser, BooleanQuery, TermQuery. Could anyone help me on this?

推荐答案

使用这个



QueryParser queryParser =新的QueryParser(Lucene。 Net.Util.Version.LUCENE_30,SearchText,SearchSettings.Instance.GetAnalyzer());



查询查询= null;



query = queryParser.Parse(Text); //搜索字符串ex:如果你想传递一个GUID值:GUID:21312412



Sort sort = new Sort(SortField.FIELD_SCORE);



TopDocs docs = IndexSearch.Search(query,1000);
use this

QueryParser queryParser = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, "SearchText", SearchSettings.Instance.GetAnalyzer());

Query query = null;

query = queryParser.Parse(Text);//search string ex: if u want pass a GUID value : GUID:21312412

Sort sort = new Sort(SortField.FIELD_SCORE);

TopDocs docs = IndexSearch.Search(query, 1000);


Check this link in this way I have solved my problem.
http://forums.asp.net/t/1935213.aspx?Search+GUID+using+lucene+net


这篇关于允许使用lucene.net搜索GUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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