Hi,

This should do the trick :  solrQuery.add(CommonParams.FQ, "fq=-{!term 
f=author}Dickens, Janet");

Ahmet


On Friday, February 28, 2014 11:21 AM, idioma <corda.ila...@gmail.com> wrote:
Ahmet,
thank you for your reply, much appreciated. Let me answer to your
question(s):

1) "Your example response (<facetEntry count="20">) looks like customized."

It is not, but I have not included the code that generates it. In a
nutshell, I have two XSLT files, one that transforms the Solr query into
something that my Web application can understand (aka as query XSLT) and one
that does a similar thing with the Solr response. 

With regard to <facetEntry>, the response XSLT includes the following (which
I have omitted before for brevity, but turned out to be relevant):

<xsl:template match="facets">
        <xsl:apply-templates select="facet" />
</xsl:template> 

<xsl:template match="facet[@name='author']">
                <sear:FACET NAME="creator" COUNT="{count(facetEntry)}">
                        <xsl:apply-templates select="facetEntry" />
                </sear:FACET>
</xsl:template>

<xsl:template match="facetEntry">
        <sear:FACET_VALUES VALUE="{@count}" KEY="{.}" />                    
    </xsl:template>

The above code allows mapping between the Solr facet field (in this case
author) and the facet code in the web application (creator). The Java class
also includes the following:

private QueryResponse execQuery(SolrQuery query) throws SolrServerException
{
    QueryResponse rsp = solrServer.query( query );
    return rsp;    

}

Element elfacets = new Element("facets"); 
            List<FacetField> facets = rsp.getFacetFields();
            if (facets != null) {
                int i = 0;
                for (FacetField facet : facets) {
                    Element sfacet = new Element("facet");
                    sfacet.setAttribute("name", facet.getName());

                    List<Count> facetEntries = facet.getValues();

                    for(FacetField.Count fcount : facetEntries) {
                        Element facetEntry = new Element("facetEntry");
                        facetEntry.setText(fcount.getName());
                        facetEntry.setAttribute("count",
String.valueOf(fcount.getCount()));
                        sfacet.addContent(facetEntry);
                    }
                    elfacets.addContent(sfacet);

            }
            root.addContent(elfacets);
        } 


        doc.addContent(root);

        return doc;
    }

This actually concerns with your second question:

"Your SolrJ program also has Element class that I have never seen"

Element is from org.jdom defines the behavior for an XML element. In my
case, it is used in the solr query response. 

The web application has a Refine check box where each box holds a facet
value that can be excluded, depending on the user's request. It is still
unclear to me where and how I should inject the exclusion variant in the
Java code. At this stage, in fact, the Exclude option works exactly as the
Include option, whereas it should return the total hits minus the subset
that falls into a specific facet value. Can you please provide examples?

Thanks,

I.



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Filter-query-exclusion-with-SolrJ-tp4119974p4120356.html

Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to