lucene.net

How do I perform an AND search in Lucene.net when multiple words are used in a search?

核能气质少年 提交于 2019-12-04 22:06:11
问题 I am playing around with Lucene.net to try and get a handle of how to implement it in my application. I have the following code ..... // Add 2 documents var doc1 = new Document(); var doc2 = new Document(); doc1.Add(new Field("id", "doc1", Field.Store.YES, Field.Index.ANALYZED)); doc1.Add(new Field("content", "This is my first document", Field.Store.YES, Field.Index.ANALYZED)); doc2.Add(new Field("id", "doc2", Field.Store.YES, Field.Index.ANALYZED)); doc2.Add(new Field("content", "The big red

PhraseQuery against title field and QueryParser against a catch all field do not result in the results I expect

99封情书 提交于 2019-12-04 21:04:39
If a user enters a phrase in the search box (with or without quotes), I want the results that show first be the documents that have the exact phrase in the document title, and other documents showing after it. This is what I have tried but it fails to give me the search results in that order: During indexing I say: AddStringFieldToDocument(document, "keyWord", this.BuildKeywordsString(), Field.Store.NO, Field.Index.ANALYZED, false); AddStringFieldToDocument(document, "title", this.Title, Field.Store.NO, Field.Index.ANALYZED, false, 4f); private void AddStringFieldToDocument(Document document,

Resources for getting started with Lucene.Net?

北城余情 提交于 2019-12-04 20:39:56
I'm building a simple site that allows users to post text content and I want to add it to a search index as it gets posted, so my site search is up to date. From what I can tell Lucene.NET is a good full text search framework. I've found very few examples of how to use it though. Can anyone post some good references for learning about Lucene? Some links: Lucene tutorial Another tutorial Lucene FAQ Lucene in action The new edition should be out soon The key point is that any Java material for Lucene is great for Lucene.net. I should note though, that from your description of requirements, Solr

Lucene.NET indexes are not updating when dealing with many-to-many relationships using NHibernate.Search

这一生的挚爱 提交于 2019-12-04 19:49:18
I have integrated NHibernate.Search into my web app by following tutorials from the following sources: NHibernate.Search using Lucene.NET Full Text Index (Part 1) Using NHibernate.Search with ActiveRecord I have also successfully batch-indexed my database, and when testing against Luke, I can search for terms that reside in whatever entities I marked as indexable. However , when I attempt to update many-to-many entities via my web app, my parent index does not seem to update. For example: public class Books { HasAndBelongsToMany(typeof(Author), Table = "BookAuthor", ColumnKey = "BookId",

Directory lock error with Lucene.Net usage in an ASP.NET MVC site

有些话、适合烂在心里 提交于 2019-12-04 18:35:54
问题 I'm building an ASP.NET MVC site where I want to use Lucene.Net for search. I've already built a SearchController and all of its methods, but I'm getting an error at runtime that occurs when the SearchController is first initialized. In SearchController, here's how I'm creating an IndexWriter: public static string IndexLocation = HostingEnvironment.MapPath("~/lucene"); public static Lucene.Net.Analysis.Standard.StandardAnalyzer analyzer = new Lucene.Net.Analysis.Standard.StandardAnalyzer();

Lucene.NET MoreLikeThis Example

雨燕双飞 提交于 2019-12-04 17:18:33
Could anyone give an example of how to use the MoreLikeThis feature in Lucene.NET. I have searched online and cannot find a single example. (Resurrecting an old question!) As an example for Lucene.Net 2.9.4g: var moreLikeThis = new Lucene.Net.Search.Similar.MoreLikeThis(indexReader); moreLikeThis.SetAnalyzer(analyzer); moreLikeThis.SetFieldNames(fieldNames); moreLikeThis.SetStopWords(stopWords); moreLikeThis.SetMinWordLen(2); var query = moreLikeThis.Like(new System.IO.StringReader(similarity)); This generates a Lucene.Net.Search.Query object that can be used to search for documents that are

How to perform a wildcard search in Lucene

天涯浪子 提交于 2019-12-04 17:09:25
I know that Lucene has extensive support for wildcard searches and I know you can search for things like: Stackover* (which will return Stackoverflow ) That said, my users aren't interested in learning a query syntax. Can Lucene perform this type of wildcard search using an out-of-box Analyzer? Or should I append "*" to every search query? Doing this with string manipulations is tricky to get right, especially since the QueryParser supports boosting, phrases, etc. You could use a QueryVisitor that rewrites TermQuery into PrefixQuery. public class PrefixRewriter : QueryVisitor { protected

Is it possible to add custom metadata to a Lucene field?

纵饮孤独 提交于 2019-12-04 15:16:54
I've come to the point where I need to store some additional data about where a particular field comes from in my Lucene.Net index. Specifically, I want to attach a guid to certain fields of a document when the field is added to the document, and retrieve it again when I get the document from a search result. Is this possible? Edit: Okay, let me clarify a bit by giving an example. Let's say I have an object that I want to allow the user to tag with custom tags like "personal", "favorite", "some-project". I do this by adding multiple "tag" fields to the document, like so: doc.Add( new Field(

Lucene .Net optimization process

送分小仙女□ 提交于 2019-12-04 14:59:35
I am creating an index using Lucene .Net 2.9.2. After a lot of indexing, the index has many segments and deleted documents, so I am calling Optimize(numSegmets) on the IndexWriter. The index's segments count is indeed reduced to the value of numSegmets , but it still has deletions... doesnt a call to Optimize should also remove all deleted documents? My question is very important so I could know if this is how Lucene works or maybe I have some bug... Edit: here is my code snippet: IndexWriter writer = new IndexWriter(/*open writer from index directroy*/); writer.Optimize(5); writer.Commit();

Fluent nhibernate + nhibernate.serach + lucene.net

ぃ、小莉子 提交于 2019-12-04 14:33:59
问题 can someone tell me how to use nhibernate serach and lucene with fluent nhibernate. I have my application writen with fluent nhibernate but now i need full text serach but do not know how to implmenet nhibernate search with lucene to fluent nhibernate. i found this but it is not much and do not know how to use it: Fluent NHibernate + Lucene Search (NHibernate.Search) thx in advanced 回答1: Lucene.net is a self-contained search and directory utility. As far as I know it cannot be integrated with