: Is there a consise way to query just a single field
: from a solr query?

At the moment, there isn't anything more concise then what you are already
getting.

What you can do though, is write a custom request handler that meets your
needs.  You wouldn't even need to loop over the Documents, you could use
the FieldCache, something like this...

  public void handleRequest(SolrQueryRequest req, SolrQueryResponse rsp) {

    ...
    Query q = // build your query however you want
    DocSet docs = req.getSearcher().getDocSet(q);
    StringBuffer buf = new StringBuffer();
    ints[] ids = FieldCache.DEFAULT.getInts
        (req.getSearcher().getReader(), "id");
    for (DocIterator i = docs.iterator(); i.hasNext(); ) {
       buf.append(ids[docs.nextDoc()]);
       buf.append(" ");
    }
    rsp.add("ids", buf.toString());
  }

(if id isn't a simple int or string, you'll need to convert it, take a
look at SolrIndexSearcher.getSchema(), IndexSchema.getFieldType(), and
FieldType.indexedToReadable)

BUT! ... if you're going to write a custom handler, you might consider
what you're doing with those ids in your client, and wether it would make
sense to put that logic in the plugin -- and really cut down on the data
sent over the wire.  (Forgive me, i don't really get what an "olap cube"
is)



-Hoss

Reply via email to