lucene.net

Highlighting whole sentence in Lucene.net 2.9.2

一世执手 提交于 2019-12-20 03:49:11
问题 Currently I'm working with the Lucene.net 2.9.2 framework. As a result of my search I would like to achieve result page (asp.net) with highlighted text fragment. I would like that the selected fragment is a whole sentence and not only few words. For example if I have text: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo

How to improve a single character PrefixQuery performance?

这一生的挚爱 提交于 2019-12-20 03:41:22
问题 I have a RAMDirectory with 1.5 million documents and I'm searching using a PrefixQuery for a single field. When the search text has a length of 3 or more characters, the search is extremely fast, less than 20 milliseconds. But when the search text has a length of less than 3 characters, the search might take even a full 1 second. Since it's an auto complete feature and the user starts with one character (and there are results that are indeed 1 char length), I cannot restrict the length of the

Using RAMDirectory

 ̄綄美尐妖づ 提交于 2019-12-18 12:56:29
问题 When should I use Lucene's RAMDirectory? What are its advantages over other storage mechanisms? Finally, where can I find a simple code example? 回答1: 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,

Lucene.NET faceted search

喜夏-厌秋 提交于 2019-12-18 12:41:10
问题 I found a great tutorial on performing a faceted search. http://www.devatwork.nl/articles/lucenenet/faceted-search-and-drill-down-lucenenet/ This article does not explain how to retrieve the narrowed available attributes to filter from (for further drill down). Lets say I am looking for planners that are red. When I perform the faceted search, I want to return all available attributes to filter from that are red. Then when I add a "weekly format" filter, I want the attribute list to get even

Lucene.NET - sorting by int

十年热恋 提交于 2019-12-18 11:56:29
问题 In the latest version of Lucene (or Lucene.NET), what is the proper way to get the search results back in sorted order? I have a document like this: var document = new Lucene.Document(); document.AddField("Text", "foobar"); document.AddField("CreationDate", DateTime.Now.Ticks.ToString()); // store the date as an int indexWriter.AddDocument(document); Now I want do a search and get my results back in order of most recent. How can I do a search that orders results by CreationDate? All the

SQL Server 2008 Full Text Search (FTS) versus Lucene.NET

非 Y 不嫁゛ 提交于 2019-12-18 09:59:21
问题 I know there have been questions in the past about SQL 2005 versus Lucene.NET but since 2008 came out and they made a lot of changes to it and was wondering if anyone can give me pros/cons (or link to an article). 回答1: I built a medium-size knowledge base (maybe 2GB of indexed text) on top of SQL Server 2005's FTS in 2006, and have now moved it to 2008's iFTS. Both situations have worked well for me, but the move from 2005 to 2008 was actually an improvement for me. My situation was NOT like

How to specify two Fields in Lucene QueryParser?

匆匆过客 提交于 2019-12-18 09:54:52
问题 I read How to incorporate multiple fields in QueryParser? but i didn't get it. At the moment i have a very strange construction like: parser = New QueryParser("bodytext", analyzer) parser2 = New QueryParser("title", analyzer) query = parser.Parse(strSuchbegriff) query2 = parser.Parse(strSuchbegriff) What can i do for something like: parser = New QuerParser ("bodytext" , "title",analyzer) query =parser.Parse(strSuchbegriff) so the Parser looks for the searching word in the field "bodytext" an

In Lucene, why do my boosted and unboosted documents get the same score?

こ雲淡風輕ζ 提交于 2019-12-18 08:10:42
问题 At index time I am boosting certain document in this way: if (myCondition) { document.SetBoost(1.2f); } But at search time documents with all the exact same qualities but some passing and some failing myCondition all end up having the same score. And here is the search code: BooleanQuery booleanQuery = new BooleanQuery(); booleanQuery.Add(new TermQuery(new Term(FieldNames.HAS_PHOTO, "y")), BooleanClause.Occur.MUST); booleanQuery.Add(new TermQuery(new Term(FieldNames.AUTHOR_TYPE, AuthorTypes

Searching phrases in Lucene

纵然是瞬间 提交于 2019-12-18 03:45:16
问题 Could somebody point me to an example how to search for phrases with Lucene.net? Let's say I have in my index a document with field "name", value "Jon Skeet". Now I want to be able to find that document when searching for "jon skeet". 回答1: You can use a proximity search to find terms within a certain distance of each other. The Lucene query syntax looks like this "jon skeet"~3 , meaning find "jon" and "skeet" within three words of each other. With this syntax, relative order doesn't matter;

How do you implement a custom filter with Lucene.net?

↘锁芯ラ 提交于 2019-12-17 23:31:57
问题 The code below is from the Lucene In Action book (originally in Java). It's for building a list of 'allowed' documents (from a user permission point of view) to filter search results with. The problem is the termsDocs.Read() method does not accept the 'doc' and 'freq' arrays to be passed by reference, so they're still empty when it comes to setting the bit in the bit array. Can anyone help, examples of using Lucene custom filters (especially in .net) seem to be thin on the ground. Thanks.