lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <karl.wri...@nokia.com>
Subject Solr query question
Date Wed, 28 Apr 2010 18:50:47 GMT
Hi Solr-knowledgeable folks,

The LCF Solr SearchComponent plugin I'm developing doesn't quite work.  The query I'm trying
to do is:

-(allow_token_document:*) and -(deny_token_document:*) and <the user's search>

The result I'm seeing is that everything in the user's search matches, unlike what I see in
the admin UI, where the above query works perfectly.

The code I'm using to do the negative wildcard searches is as follows:

  public void prepare(ResponseBuilder rb) throws IOException
  {
      BooleanFilter bf = new BooleanFilter();
    

      // No authenticated user name; only return 'public' documents (those with no security
tokens at all)
      // That query is:
      // (fieldAllowShare is empty AND fieldDenyShare is empty AND fieldAllowDocument is empty
AND fieldDenyDocument is empty)

      // We're trying to map to:  -(fieldAllowShare:*) , which should be pretty efficient
in Solr because it is negated.  If this turns out not to be so, then we should
      // have the SolrConnector inject a special token into these fields when they otherwise
would be empty, and we can trivially match on that token.
      
      bf.add(new FilterClause(new WildcardFilter(new Term(fieldAllowDocument,"*")),BooleanClause.Occur.MUST_NOT));
      bf.add(new FilterClause(new WildcardFilter(new Term(fieldDenyDocument,"*")),BooleanClause.Occur.MUST_NOT));

     // Concatenate with the user's original query.
     FilteredQuery query = new FilteredQuery(rb.getQuery(),bf);
     rb.setQuery(query);
  }


Any hints welcome!
Karl


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


Mime
View raw message