Vb.net BooleanQuery已运行,但无法运行
我有以下代码Vb.net BooleanQuery已运行,但无法运行,vb.net,lucene.net,Vb.net,Lucene.net,我有以下代码 Dim term1 As Lucene.Net.Index.Term = New Lucene.Net.Index.Term("contents", "technical") Dim term2 As Lucene.Net.Index.Term = New Lucene.Net.Index.Term("contents", "c++") Dim span1 As SpanQuery = New SpanTermQuery(term1) Dim span2 A
Dim term1 As Lucene.Net.Index.Term = New Lucene.Net.Index.Term("contents", "technical")
Dim term2 As Lucene.Net.Index.Term = New Lucene.Net.Index.Term("contents", "c++")
Dim span1 As SpanQuery = New SpanTermQuery(term1)
Dim span2 As SpanQuery = New SpanTermQuery(term2)
Dim spanQuery As SpanNearQuery = New SpanNearQuery(New SpanQuery() {
span1,
span2},
2000000,
False
)
Dim booleanQuery As BooleanQuery = New BooleanQuery()
booleanQuery.SetMinimumNumberShouldMatch(0)
booleanQuery.Add(span1, BooleanClause.Occur.SHOULD)
booleanQuery.Add(span2, BooleanClause.Occur.SHOULD)
现在,如果我搜索布尔查询,它会返回一些文档,但如果我搜索PanerarQuery,它不会返回任何文档
这是我的索引代码
Dim indexLocation As String = "C:/index"
Dim directory As Lucene.Net.Store.Directory = Lucene.Net.Store.FSDirectory.Open(New DirectoryInfo(indexLocation))
'create an analyzer to process the text
Dim analyzer As Lucene.Net.Analysis.Analyzer = New Lucene.Net.Analysis.Standard.StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29)
'creating an index writer to write the doc to index
Dim deletionPolicy As Lucene.Net.Index.IndexDeletionPolicy = New Lucene.Net.Index.KeepOnlyLastCommitDeletionPolicy()
Dim indexWriter As Lucene.Net.Index.IndexWriter = New Lucene.Net.Index.IndexWriter(directory, analyzer, True, deletionPolicy, Lucene.Net.Index.IndexWriter.MaxFieldLength.UNLIMITED)
Dim files() As String
files = System.IO.Directory.GetFiles("C:\ResumeDirectory\")
For i As Integer = 0 To files.Length - 1
Dim streamReader As StreamReader = New StreamReader(files(i))
Dim docField1 As Field = New Field("contents", streamReader, Lucene.Net.Documents.Field.TermVector.YES)
Dim docField2 As Field = New Field("CandidateID", files(i), Field.Store.YES, Field.Index.NOT_ANALYZED)
Dim doc As Document = New Document()
doc.Add(docField1)
doc.Add(docField2)
'writing the document to index
indexWriter.AddDocument(doc)
streamReader.Close()
Next
'optimize and close the writer
indexWriter.Optimize()
indexWriter.Dispose()
End Sub
我的PanerarQuery代码有什么问题吗?显示一些索引代码,也许这有助于找出您的问题所在is@Beaulac看看我的编辑。