Пример #1
0
        //////////////////////////////////////////////////////////////////////////////////

        protected void AddIndexable(Indexable indexable)
        {
            indexable.Source = QueryDriver.GetQueryable(this).Name;

            lock (request_lock)
                pending_request.Add(indexable);

            // Schedule a final flush every time we add anything.
            // Better safe than sorry.
            ScheduleFinalFlush();
        }
Пример #2
0
        public ISnippetReader GetSnippet(string[] query_terms, Hit hit, bool full_text, int ctx_length, int snp_length)
        {
            if (hit == null)
            {
                return(null);
            }

            // Sanity-check: make sure this Hit actually came out of this Queryable
            if (QueryDriver.GetQueryable(hit.Source) != this)
            {
                string msg = String.Format("Queryable mismatch in GetSnippet: {0} vs {1}", hit.Source, this);
                throw new Exception(msg);
            }

            try {
                return(iqueryable.GetSnippet(query_terms, hit, full_text, ctx_length, snp_length));
            } catch (Exception ex) {
                Logger.Log.Warn(ex, "Caught exception calling DoQuery on '{0}'", Name);
            }

            return(null);
        }
Пример #3
0
        public override ResponseMessage Execute(RequestMessage req)
        {
            SnippetRequest request   = (SnippetRequest)req;
            Queryable      queryable = QueryDriver.GetQueryable(request.Hit.Source);
            ISnippetReader snippet_reader;
            bool           full_text  = request.FullText;
            int            ctx_length = request.ContextLength;
            int            snp_length = request.SnippetLength;

            if (queryable == null)
            {
                Log.Error("SnippetExecutor: No queryable object matches '{0}'", request.Hit.Source);
                snippet_reader = new SnippetReader(null, null, false, -1, -1);
                full_text      = false;
            }
            else
            {
                snippet_reader = queryable.GetSnippet(request.QueryTerms, request.Hit, full_text, ctx_length, snp_length);
            }

            return(new SnippetResponse(new SnippetList(full_text, snippet_reader)));
        }