lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rafał Kuć <r....@solr.pl>
Subject Re: Restrict Lucene search in concrete document ids
Date Mon, 22 Oct 2012 14:04:11 GMT
Hello!

I think you should ask about Lucene.NET on the proper mailing list
dedicated to it, instead on the current one which is dedicated to Java
version of Lucene.

You can find the proper mailing addresses here: http://lucenenet.apache.org/community.html

-- 
Regards,
 Rafał Kuć
 Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch

> I work with Lucene.Net. , version 2.9
> The code is :

> Searching:
> Filter filter = new PictureIdFilter( allowedResources );
> TopDocs docs = searcher.Search( boolQuery, filter, documentCount );
> ScoreDoc[] hits = docs.scoreDocs;

> And the filter is :

> class PictureIdFilter : Filter
> +    {
> +        ILog log = LogManager.GetLogger("PictureIdFilter");
> +        private BitArray bits;
> +
> +        private HashSet<String> bag;
> +
> +        public PictureIdFilter(ResourceKey[] allowedResources)
> +        {
> +            var sw = new Stopwatch();
> +            sw.Start();
> +            bag = new HashSet<string>(allowedResources.Select(
x=>>x.ResourceId.ToString() ));
> +            sw.Stop();
> +            log.Warn("PictureIdFilter hashset create: " +
> sw.ElapsedMilliseconds);
> +        }
> +
> +        public override BitArray Bits(IndexReader reader)
> +        {
> +            var maxDoc = reader.MaxDoc();
> +            log.Warn("PictureIdFilter maxdoc: " + maxDoc);
> +            var result = new BitArray(maxDoc);
> +            var sw = new Stopwatch();
> +            sw.Start();
> +            for (int i = 0; i < maxDoc; i++)
> +            {
> +                var doc = reader.Document( i );
> +                Field field = doc.GetField( "IDPicture" );
> +                string fieldValue = field.StringValue();
> +                if (bag.Contains( fieldValue ))
> +                {
> +                    result[i] = true;
> +                }
> +            }
> +            sw.Stop();
> +            log.Warn("PictureIdFilter going over results: " +
> sw.ElapsedMilliseconds);
> +            return result;
> +        }
> +    }

> The problem with that code is that it takes too much time.. That's why I
> tried to filter by DocumentId somehow, but couldn't find the proper ifc.



> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Restrict-Lucene-search-in-concrete-document-ids-tp4013905p4015123.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message