incubator-blur-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Rohr <rohr.ch...@gmail.com>
Subject Re: Some 0.2 questions
Date Mon, 21 Jan 2013 17:21:19 GMT
Thanks Aaron, that helps a lot.

Chris

On Jan 21, 2013, at 8:20 AM, Aaron McCurry <amccurry@gmail.com> wrote:

> On Sun, Jan 20, 2013 at 11:12 PM, Chris Rohr <rohr.chris@gmail.com> wrote:
> 
>> Hi everyone,
>> 
>> First time poster here but have been using 0.1.x for quite a while.  I've
>> gotten 0.2 up and running and I had a couple of implementation questions.
>> 
>> 1. Can you explain how the session object in the thrift interface is
>> supposed to be used?
>> 
> 
> The session object creates a snapshot of the indexes during a search and
> fetch of the documents.  Because search and fetch are 2 different calls
> this ensures that the document id can not change during searching.
> (Document ids can change from Lucene generation to generation)
> 
> 
>> 
>> 2. Is the SimpleQuery concept from 0.1.x gone in 0.2?
>> 
> 
> No, it's still possible.  I have included some sample code below.
> 
> 
>> 
>> 3. If I was to use CDH, which version is recommended for 0.2?
>> 
> 
> CDH3 is the only version that Blur has been tested with, use the lastest
> update from Cloudera if you are using CDH3.  I think that update 5 (CDHu5)
> is the latest.
> 
> 
>> 
>> Thank you in advance,
>> Chris
> 
> 
> 
> // This takes the place of simple query
> Query query = new Query();
> query.setType(QueryType.STRING);
> query.setQueryString(queryStr);
> 
> QueryArgs queryArgs = new QueryArgs();
> queryArgs.setQuery(query);
> // This tells the server to only return a single TopFieldDocs in the search
> call
> // instead of a TopFieldDocs object per shard in the table.  NOTE: I can't
> // remember if I've actually written the aggregate function.
> queryArgs.setAggregateResults(true);
> 
> // Creates a snapshot of the indexes
> Session session = client.openReadSession(tablename);
> 
> // Runs the search
> List<TopFieldDocs> topDocs = client.search(session, queryArgs);
> 
> // Gets the document locations form the TopFieldDocs
> TopFieldDocs topFieldDocs = topDocs.iterator().next();
> List<Long> docLocations = BlurThriftUtil.toDocLocations(topFieldDocs);
> 
> // This fetches all of the documents with all their fields.
> List<Document> docs = client.doc(session, docLocations, null);
> long totalHits = topFieldDocs.getTotalHits();
> out.println("Totalhits " + totalHits);
> print(docs, docLocations, showDocLocations, showBoost, showType, out,
> maxLineWidth);
> 
> // Closes the session.
> client.closeReadSession(session);


Mime
View raw message