lucene.net

How to sort by Lucene.Net field and ignore common stop words such as 'a' and 'the'?

≯℡__Kan透↙ 提交于 2020-01-23 19:26:27
问题 I've found how to sort query results by a given field in a Lucene.Net index instead of by score; all it takes is a field that is indexed but not tokenized. However, what I haven't been able to figure out is how to sort that field while ignoring stop words such as "a" and "the", so that the following book titles, for example, would sort in ascending order like so: The Cat in the Hat Horton Hears a Who Is such a thing possible, and if yes, how? I'm using Lucene.Net 2.3.1.2. 回答1: I wrap the

Lucene.net Field contains mutiple values and who to search

混江龙づ霸主 提交于 2020-01-23 17:02:06
问题 Anyone know what the best way is to search on a Field that hold multiple values? string tagString = ""; foreach(var tag in tags) { tagString = tagString += ":" + tag; } doc.Field(new Field("Tags", tagString, Field.Store.YES, Field.Index.Analyzed); Let's say I want to search for all documents that has the tag "csharp", who could I best implement this? 回答1: I think what you are looking for is adding multiple fields with the same name to a single Document . What you do is create a single

Using a Combination of Wildcards and Stemming

时光怂恿深爱的人放手 提交于 2020-01-21 01:50:07
问题 I'm using a snowball analyzer to stem the titles of multiple documents. Everything works well, but their are some quirks. Example: A search for "valv", "valve", or "valves" returns the same number of results. This makes sense since the snowball analyzer reduces everything down to "valv". I run into problems when using a wildcard. A search for "valve*" or "valves*" does not return any results. Searching for "valv*" works as expected. I understand why this is happening, but I don't know how to

Lucene.NET TokenStream.Next method disappeared

若如初见. 提交于 2020-01-16 20:34:06
问题 I have to update a project using Lucene.NET. It first time I meet this library, and I should update the references to a new version. So I did with Lucene references via a NuGet. But actually I should in a way update some methods that disappeared in the new versions. public abstract class AnalyzerView { public abstract string Name { get; } public virtual string GetView(TokenStream tokenStream,out int numberOfTokens) { StringBuilder sb = new StringBuilder(); Token token = tokenStream.Next();

Complex Phrases and/or ComplexPhraseQueryParser in Lucene.NET

倖福魔咒の 提交于 2020-01-15 23:38:47
问题 I am trying to search for fairly complex queries with Lucene.Net like "inject* needle*" OR "point* thingy"~2 So basically I need wildcards in regular as well as proximity phrases. However, the basic Lucene.Net QueryParser gets rid of these wildcards. I understand that ComplexPhraseQueryParser would work for that, unfortunately this is not included in Lucene.Net. Is there any way of constructing queries like this in Lucene.Net? 回答1: I ended up by actually porting the ComplexPhraseQueryParser

Unable to delete the existing document in lucene index

筅森魡賤 提交于 2020-01-15 12:47:32
问题 I am using Lucene.Net (version 2.9.4.1) to implement a simple search module. I'm trying to delete the document if it exists in the index using the following code, var analyzer = new StandardAnalyzer(Version.LUCENE_29); var indexWriter = new IndexWriter( LuceneSearch._luceneDir, analyzer, IndexWriter.MaxFieldLength.UNLIMITED); var searchQuery = new TermQuery(new Term("ListID", listingDoc.Get("ListID"))); indexWriter.DeleteDocuments(searchQuery); where listingDoc is of type Document i'm trying

lucene.net phonetic filter

蓝咒 提交于 2020-01-15 04:32:26
问题 I am trying to store text data to lucene. The search should be with phonetic! Where should I add a phonetic filter? Lucene.Net.Store.Directory dir = FSDirectory.Open(new DirectoryInfo(Application.StartupPath + "\\Index")); IndexReader indexReader = IndexReader.Open(dir, true); Searcher indexSearch = new IndexSearcher(indexReader); //IndexReader indexReader = IndexReader.Open(dir, true); //Searcher indexSearch = new IndexSearcher(indexReader); Analyzer analyzer = new Lucene.Net.Analysis.De

Lucene.net Fuzzy Phrase Search

感情迁移 提交于 2020-01-13 13:45:11
问题 I have tried this myself for a considerable period and looked everywhere around the net - but have been unable to find ANY examples of Fuzzy Phrase searching via Lucene.NET 2.9.2. ( C# ) Is something able to advise how to do this in detail and/or provide some example code - I would seriously seriously appreciate any help as I am totally stuck ? 回答1: I assume that you have Lucene running and created a search index with some fields in it. So let's assume further that: var fields = ... // a

Handling + as a special character in Lucene search

拟墨画扇 提交于 2020-01-12 18:35:49
问题 How do i make sure lucene gives me back relevant search results when my input string contains terms like c++? Lucene seems to ignore ++ characters. Code details: When I execute this line,I get a blank search query. queryField = multiFieldQueryParser.Parse(inpKeywords); keywordsQuery.Add(queryField, BooleanClause.Occur.SHOULD); And here is my custom analyzer: public class CustomAnalyzer : Analyzer { private static readonly WhitespaceAnalyzer whitespaceAnalyzer = new WhitespaceAnalyzer();

Indexing Json Object Arrays in Lucene.NET

北城以北 提交于 2020-01-12 09:20:37
问题 I am working on putting arbitrary json objects into a Lucene.NET index, given an object that might look like: { name: "Tony", age: 40, address: { street: "Weakroad", number: 10, floor: 2, door: "Left" }, skills: [ { name: ".NET", level: 5, experience: 12 }, { name: "JavaScript", level: 3, experience: 6 }, { name: "HTML5", level: 4, experience: 6 }, { name: "Lucene.NET", level: 1, experience: 12 }, { name: "C#", level: 10, experience: 12 } ], aliases: [ "Bucks", "SirTalk", "BeemerBoy" ] } That