lucenenet-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shad Storhaug <s...@shadstorhaug.com>
Subject RE: Lucene 4.8 IndexSearcher question
Date Tue, 16 May 2017 02:04:05 GMT
Here is an example: https://github.com/NightOwl888/LuceneNetDemo/blob/master/LuceneNetDemo/GitHubIndex.cs#L157-L183

>> One other thing I noticed is that the Lucene.Net.Index.Term used to be reusable.
Even the comments state that it should be reusable (even in Java 5.4<https://lucene.apache.org/core/5_4_0/core/org/apache/lucene/index/Term.html>).
>> Yet I don't see a way to reuse it and change the 'text' portion, given the current
fields/methods.

>Be sure you are looking at the documentation for the correct Lucene version: https://lucene.apache.org/core/4_8_0/core/org/apache/lucene/index/Term.html.
In 4.8, the Term was copied directly. It wasn't made reusable until 5.4. Of course, it is
simple enough to make a reusable term:

> BytesRef bytes = new BytesRef("foo");
> var term = new Term(BytesRef.DeepCopyOf(bytes));

Oops, that should have been:

BytesRef bytes = new BytesRef("foo");
var term = new Term("fieldName", BytesRef.DeepCopyOf(bytes));


-----Original Message-----
From: Shad Storhaug [mailto:shad@shadstorhaug.com] 
Sent: Tuesday, May 16, 2017 8:55 AM
To: user@lucenenet.apache.org
Subject: RE: Lucene 4.8 IndexSearcher question

Matt,

> Did your SearcherManager.ExecuteSearch() get removed from the releases?

As this API was not appropriately marked as LUCENENET specific, it has inadvertently been
removed because it did not exist in the original source. But after analysis of the API, this
pattern lends itself better to a using block rather than using delegate methods. I have been
experimenting with adding such an API as an extension method to the ReferenceManager<T>,
so it would apply not just to the SearchManager, but also to its other subclasses as well.

In the meantime, you should use the original Lucene API, which is intended to be used in a
try-finally block:

var searcher = searchManger.Acquire()
try
{
    // Do your logic here...
}
finally
{
    searchManager.Release(searcher);
}

Here is an example: https://github.com/NightOwl888/LuceneNetDemo/blob/master/LuceneNetDemo/GitHubIndex.cs#L157-L183

> One other thing I noticed is that the Lucene.Net.Index.Term used to be reusable. Even
the comments state that it should be reusable (even in Java 5.4<https://lucene.apache.org/core/5_4_0/core/org/apache/lucene/index/Term.html>).
> Yet I don't see a way to reuse it and change the 'text' portion, given the current fields/methods.

Be sure you are looking at the documentation for the correct Lucene version: https://lucene.apache.org/core/4_8_0/core/org/apache/lucene/index/Term.html.
In 4.8, the Term was copied directly. It wasn't made reusable until 5.4. Of course, it is
simple enough to make a reusable term:

BytesRef bytes = new BytesRef("foo");
var term = new Term(BytesRef.DeepCopyOf(bytes));

Thanks,
Shad Storhaug (NightOwl888)


-----Original Message-----
From: Matt Diehl [mailto:mdiehl@lexprompt.com.INVALID]
Sent: Tuesday, May 16, 2017 6:31 AM
To: user@lucenenet.apache.org
Subject: Re: Lucene 4.8 IndexSearcher question

Hi Itamar,

Did your SearcherManager.ExecuteSearch() get removed from the releases? I your example uses
the code, but I don't see this in the release:
https://www.myget.org/feed/lucene-net-ci/package/nuget/Lucene.Net  - Lucene.Net.4.8.0-ci0000001084\lib\net451\Lucene.Net.dll

Here's the original commit:
https://www.mail-archive.com/commits@lucenenet.apache.org/msg01225.html

One other thing I noticed is that the Lucene.Net.Index.Term used to be reusable. Even the
comments state that it should be reusable (even in Java
5.4
<https://lucene.apache.org/core/5_4_0/core/org/apache/lucene/index/Term.html>).
Yet I don't see a way to reuse it and change the 'text' portion, given the current fields/methods.

Thanks, Matt

On Mon, Dec 12, 2016 at 12:24 PM, Itamar Syn-Hershko <itamar@code972.com>
wrote:

> You can have several, but better to use the new SearcherManager to 
> manage that for you. See the sample here:
> https://github.com/synhershko/LuceneNetDemo
>
> --
>
> Itamar Syn-Hershko
> http://code972.com | @synhershko <https://twitter.com/synhershko> 
> Freelance Developer & Consultant Lucene.NET committer and PMC member
>
> On Mon, Dec 12, 2016 at 8:48 PM, Monica Black <ml_black@hotmail.com>
> wrote:
>
> > Hi, all.
> >
> >
> > So happy you've revived Lucene.NET--hoping to see some more current 
> > news soon.
> >
> >
> > I want to create a web service to access Lucene Index I've made--how 
> > many concurrent IndexSearchers could I have over the same index?  Do 
> > you anticipate any issues with this approach?
> >
> >
> > Thanks!
> > Monica
> >
>
Mime
View raw message