I faced the same problem and my approach was encapsulate the result TopDocs in an YourObject and then remove/filter the undesirable ones using Linq:

        public IQueryable<YourObject> Search(string searchQuery)
        {
TopDocs topDocs = Searcher.PerformSearch(GetIndexSearcher(), searchQuery);

            List<YourObject> list = new List<YourObject>();

            foreach (ScoreDoc scoreDoc in topDocs.scoreDocs)
            {
                Document doc = GetIndexSearcher().Doc(scoreDoc.doc);
                float score = scoreDoc.score;

                list.Add(YourObjectWrapper.Wrap(doc, "venda", score));
            }

            return listaImoveis.AsQueryable();
        }

    public static class YourObjectWrapper
    {
        public static YourObject Wrap(Document doc, float score)
        {
            YourObject yourObject = new YourObject(doc.Get("Id"));
            yourObject.ResultScore = score;

            return yourObject;
        }
    }



Em 10/11/2011 14:51, Trevor Watson escreveu:
We'd like to have the ability to exclude items from a search given the ID (the ID is a link between a database for frequently updated information and the index for searching).

Optimally, it'd be great if we could just run the query vs the index AND the database, but I haven't found anything for doing that (using SQLite).

Would this be a custom Filter? I've dealt with custom analyzers in the past, but that wouldn't be useful here. Is there an existing filter where we can say "ignore these documents?"

Thanks in advance.

Trevor Watson


Reply via email to