lucene.net

Lucene RangeQuery doesn't filter appropriately

二次信任 提交于 2019-11-30 20:28:15
I'm using RangeQuery to get all the documents which have amount between say 0 to 2. When i execute the query, Lucene gives me documents which have amount greater than 2 also. What am I missing here? Here is my code: Term lowerTerm = new Term("amount", minAmount); Term upperTerm = new Term("amount", maxAmount); RangeQuery amountQuery = new RangeQuery(lowerTerm, upperTerm, true); finalQuery.Add(amountQuery, BooleanClause.Occur.MUST); and here is what goes into my index: doc.Add(new Field("amount", amount.ToString(), Field.Store.YES, Field.Index.UN_TOKENIZED, Field.TermVector.YES)); UPDATE : Like

TermQuery not returning on a known search term, but WildcardQuery does

大憨熊 提交于 2019-11-30 20:19:01
Am hoping someone with enough insight into the inner workings of Lucene might be able to point me in the right direction =) I'll skip most of the surrounding irellevant code, and cut right to the chase. I have a Lucene index, to which I am adding the following field to the index (variables replaced by their literal values): document.Add( new Field("Typenummer", "E5CEB501A244410EB1FFC4761F79E7B7", Field.Store.YES , Field.Index.UN_TOKENIZED)); Later, when I search my index (using other types of queries), I am able to verify that this field does indeed appear in my index - like when looping

Lucene - Wildcards in phrases

五迷三道 提交于 2019-11-30 18:21:22
I am currently attempting to use Lucene to search data populated in an index. I can match on exact phrases by enclosing it in brackets (i.e. "Processing Documents"), but cannot get Lucene to find that phrase by doing any sort of "Processing Document*". The obvious difference being the wildcard at the end. I am currently attempting to use Luke to view and search the index. (it drops the asterisk at the end of the phrase when parsing) Adding the quotes around the data seems to be the main culprit as searching for document* will work, but "document*" does not Any assistance would be greatly

Can someone explain to me what this GetCardinality method is doing?

人走茶凉 提交于 2019-11-30 11:42:38
问题 I've been looking into faceted search with Lucene.NET, I've found a brilliant example here which explains a fair amount, apart from the fact that it completely overlooks the function which checks the cardinality of items in a bit array. Can anyone give me a run down of what it is doing? The main things I don't understand is why the bitsSetArray is created as it is, what it is used for and how all the if statements work in the for loop. This may be a big ask but I have to understand how this

Lucene.Net writing/reading synchronization

我是研究僧i 提交于 2019-11-30 09:02:55
Could I write (with IndexWriter ) new documents into index while it is opened for reading (with IndexReader )? Or must I close reading before writing? Could I read/search documents (with IndexReader ) in index while it is opened for writing (with IndexWriter )? Or must I close writing before reading? Is Lucene.Net thread safely or not? Or must I write my own? You may have any amount of readers/searchers opened at any time, but only one writer. This is enforced by a directory specific lock, usually involving a file named "write.lock". Readers open snapshots, and writers adds more data to the

Using RAMDirectory

允我心安 提交于 2019-11-30 08:35:18
When should I use Lucene's RAMDirectory? What are its advantages over other storage mechanisms? Finally, where can I find a simple code example? When you don’t want to permanently store your index data. I use this for testing purposes. Add data to your RAMDirectory, Do your unit tests in RAMDir. e.g. public static void main(String[] args) { try { Directory directory = new RAMDirectory(); Analyzer analyzer = new SimpleAnalyzer(); IndexWriter writer = new IndexWriter(directory, analyzer, true); OR public void testRAMDirectory () throws IOException { Directory dir = FSDirectory.getDirectory

Lucene.Net: How can I add a date filter to my search results?

倖福魔咒の 提交于 2019-11-30 07:23:40
I've got my searcher working really well, however it does tend to return results that are obsolete. My site is much like NerdDinner whereby events in the past become irrelevant. I'm currently indexing like this note: my example is in VB.NET, but I don't care if examples are given in C# Public Function AddIndex(ByVal searchableEvent As [Event]) As Boolean Implements ILuceneService.AddIndex Dim writer As New IndexWriter(luceneDirectory, New StandardAnalyzer(), False) Dim doc As Document = New Document doc.Add(New Field("id", searchableEvent.ID, Field.Store.YES, Field.Index.UN_TOKENIZED)) doc.Add

Lucene RangeQuery doesn't filter appropriately

南笙酒味 提交于 2019-11-30 05:39:13
问题 I'm using RangeQuery to get all the documents which have amount between say 0 to 2. When i execute the query, Lucene gives me documents which have amount greater than 2 also. What am I missing here? Here is my code: Term lowerTerm = new Term("amount", minAmount); Term upperTerm = new Term("amount", maxAmount); RangeQuery amountQuery = new RangeQuery(lowerTerm, upperTerm, true); finalQuery.Add(amountQuery, BooleanClause.Occur.MUST); and here is what goes into my index: doc.Add(new Field(

TermQuery not returning on a known search term, but WildcardQuery does

南楼画角 提交于 2019-11-30 04:53:37
问题 Am hoping someone with enough insight into the inner workings of Lucene might be able to point me in the right direction =) I'll skip most of the surrounding irellevant code, and cut right to the chase. I have a Lucene index, to which I am adding the following field to the index (variables replaced by their literal values): document.Add( new Field("Typenummer", "E5CEB501A244410EB1FFC4761F79E7B7", Field.Store.YES , Field.Index.UN_TOKENIZED)); Later, when I search my index (using other types of

How to enable stemming when searching using lucene.net?

我与影子孤独终老i 提交于 2019-11-30 03:57:39
How to enable stemming when searching using lucene.net? To do this you need to write your own analyzer class. This is relatively straightforward. Here is the one that I am using. It combines stop word filtering. Porter stemming and (this may be too much for your needs) stripping of accents from characters. /// <summary> /// An analyzer that implements a number of filters. Including porter stemming, /// Diacritic stripping, and stop word filtering. /// </summary> public class CustomAnalyzer : Analyzer { /// <summary> /// A rather short list of stop words that is fine for basic search use. /// <