4
通过搜索的字符串i
是(Experience:[1 TO 5])
它像搜索15所有号码,25,21,51,等我需要的数字1和5之间进行搜索,为什么Lucene数字范围搜索不起作用?
using Lucene.Net.Store;
var results = new List<SearchResults>();
// Specify the location where the index files are stored
string indexFileLocation = @"G:\Lucene.Net\Data\Document";
var dir = Lucene.Net.Store.FSDirectory.GetDirectory(indexFileLocation);
var reader = IndexReader.Open(dir);
var searcher = new IndexSearcher(reader);
var analyzer = new StandardAnalyzer();
var queryParser = new QueryParser("Prof_ID", analyzer);
// <default field> is the field that QueryParser will search if you don't
string special = "";
if (!txtkeyword.Text.Equals(""))
{
special = special + "(Experience:[1 TO 5])";
}
var hits = searcher.Search(queryParser.Parse(special));
// Getting result to the list
for (int i = 0; i < hits.Length(); i++)
{
SearchResults result = new SearchResults();
result.Skillsummarry = hits.Doc(i).GetField("JS_Skill_Summary").StringValue();
result.Experience = hits.Doc(i).GetField("Experience").StringValue();
result.Profile_Id = hits.Doc(i).GetField("Prof_ID").StringValue();
results.Add(result);
}
GridView1.DataSource = results;
GridView1.DataBind();
对不起,你的问题不是很清楚。请编辑你的问题,并试图弄清楚什么可行,你想达到什么目的。 – wonko79
您需要显示如何为数据编制索引,以及数据的外观。此代码只是显示您如何查询现有索引。 –