You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Gabriele Kahlout <ga...@mysimpatico.com> on 2011/05/15 13:15:16 UTC

How to get the filtered terms from a Query in the ResponseWriter?

Hello,

For a given q string I'm trying to extract the terms (identifiers of tokens)
that the Query Parser identified at terms (and shows when explaining
results). I manage to do it as follows, but *I hope there a better way (more
direct) you will tell me about:*


NamedList analysis = new *FieldAnalysisRequestHandler*().doAnalysis(request);
//doAnalyis is protected, should extend with own dummy to get bypass, but
for now just hack
            SimpleOrderedMap fieldsMap = (SimpleOrderedMap)
analysis.get("field_names");
            SimpleOrderedMap contentMap = (SimpleOrderedMap)
fieldsMap.get("content");
            final Set terms = new HashSet();
            for (Object object : contentMap) {
                List termsList = (List) object;
                for (Object object1 : termsList) {
                    SimpleOrderedMap termMap = (SimpleOrderedMap) object1;
                     *terms.add((String) termMap.get("text")); *//actually I
want the intersection of the terms returned here (i.e. those that made
through all the filters, and not the union
                }
            }





-- 
Regards,
K. Gabriele

--- unchanged since 20/9/10 ---
P.S. If the subject contains "[LON]" or the addressee acknowledges the
receipt within 48 hours then I don't resend the email.
subject(this) ∈ L(LON*) ∨ ∃x. (x ∈ MyInbox ∧ Acknowledges(x, this) ∧ time(x)
< Now + 48h) ⇒ ¬resend(I, this).

If an email is sent by a sender that is not a trusted contact or the email
does not contain a valid code then the email is not received. A valid code
starts with a hyphen and ends with "X".
∀x. x ∈ MyInbox ⇒ from(x) ∈ MySafeSenderList ∨ (∃y. y ∈ subject(x) ∧ y ∈
L(-[a-z]+[0-9]X)).