Bulk builder not working

I am new to ElasticSearch. I tried the sample BulkRequestBuilder code to
populate the index, but when i am retrieving the index by a query it gives
0 hits.
i am using the following code for indexing. Please help

public void createIndex() throws IOException {
try {
    BulkRequestBuilder bulkRequest = client.prepareBulk();

client.admin().indices().prepareCreate(indexName).execute().actionGet();

    IndexRequestBuilder req = client.prepareIndex("twitter", "tweet", 

"1")
.setSource(jsonBuilder()
.startObject()
.field("user", "kimchy")
.field("postDate", "12 June")
.field("message", "trying out Elastic Search")
.endObject()
);
bulkRequest.add(req);

    bulkRequest.add(client.prepareIndex("twitter", "tweet", "2")
            .setSource(jsonBuilder()
                        .startObject()
                            .field("user", "kimchy")
                            .field("postDate", "12 June")
                            .field("message", "another post")
                        .endObject()
                      )
            );
    
    BulkResponse bulkResponse = bulkRequest.execute().actionGet();
    System.out.println("Added documents");

    if (bulkResponse.hasFailures()) {
        System.out.println("Error");
    }
}
    
    
    
catch (IndexAlreadyExistsException e) {
    System.out.println("Index already exists");
}
}

the search code is:

public SearchHits search(String fieldName, String value) {
TermQueryBuilder query = new TermQueryBuilder(fieldName, value);
//System.out.println(query);
 return 

client.prepareSearch(indexName).setTypes("tweet").setExplain(true).setQuery(query).execute().actionGet().getHits();
}

("user", "kimchy") are the passes parameters.

Are you using the default mapping? Your are using a TermQuery, which
should be used only on non-analyzed fields. That said, the term
"kimchy" should be the same, analyzed or not. Is indexName = to
"twitter"? Any errors in bulkResponse? Check
bulkResponse.items().length and bulkResponse.hasFailures().

--
Ivan

On Tue, Jun 12, 2012 at 5:24 AM, Saurabh saurabh.k1510@gmail.com wrote:

the search code is:

public SearchHits search(String fieldName, String value) {
TermQueryBuilder query = new TermQueryBuilder(fieldName, value);
//System.out.println(query);
 return

client.prepareSearch(indexName).setTypes("tweet").setExplain(true).setQuery(query).execute().actionGet().getHits();
}

("user", "kimchy") are the passes parameters.

Yes, the mapping is default and the indexName is "twitter". bulkResponse
does not have any failures. Is there any way to check whether the documents
are added in the index?

On Tue, Jun 12, 2012 at 10:33 PM, Ivan Brusic ivan@brusic.com wrote:

Are you using the default mapping? Your are using a TermQuery, which
should be used only on non-analyzed fields. That said, the term
"kimchy" should be the same, analyzed or not. Is indexName = to
"twitter"? Any errors in bulkResponse? Check
bulkResponse.items().length and bulkResponse.hasFailures().

--
Ivan

On Tue, Jun 12, 2012 at 5:24 AM, Saurabh saurabh.k1510@gmail.com wrote:

the search code is:

public SearchHits search(String fieldName, String value) {
TermQueryBuilder query = new TermQueryBuilder(fieldName, value);
//System.out.println(query);
 return

client.prepareSearch(indexName).setTypes("tweet").setExplain(true).setQuery(query).execute().actionGet().getHits();

}

("user", "kimchy") are the passes parameters.

--
Saurabh Kumar
M.Sc (Mathematics) B.E (Computer Science)
Birla Institute of Technology and Science-Pilani

After a bit of researching i got a small app that tells number of document
in the ES index. I ran that application, and figured out that the documents
are not getting added to the index. The search code looks fine to me. Any
idea why the documents are not getting added using bulkRequestBuilder?

On Tue, Jun 12, 2012 at 10:51 PM, Saurabh Kumar saurabh.k1510@gmail.comwrote:

Yes, the mapping is default and the indexName is "twitter". bulkResponse
does not have any failures. Is there any way to check whether the documents
are added in the index?

On Tue, Jun 12, 2012 at 10:33 PM, Ivan Brusic ivan@brusic.com wrote:

Are you using the default mapping? Your are using a TermQuery, which
should be used only on non-analyzed fields. That said, the term
"kimchy" should be the same, analyzed or not. Is indexName = to
"twitter"? Any errors in bulkResponse? Check
bulkResponse.items().length and bulkResponse.hasFailures().

--
Ivan

On Tue, Jun 12, 2012 at 5:24 AM, Saurabh saurabh.k1510@gmail.com wrote:

the search code is:

public SearchHits search(String fieldName, String value) {
TermQueryBuilder query = new TermQueryBuilder(fieldName, value);
//System.out.println(query);
 return

client.prepareSearch(indexName).setTypes("tweet").setExplain(true).setQuery(query).execute().actionGet().getHits();

}

("user", "kimchy") are the passes parameters.

--
Saurabh Kumar
M.Sc (Mathematics) B.E (Computer Science)
Birla Institute of Technology and Science-Pilani

--
Saurabh Kumar
M.Sc (Mathematics) B.E (Computer Science)
Birla Institute of Technology and Science-Pilani

I got the answer. I was doing the search wrong, I gave the type as "tweet"
but while searching i was only giving fieldName as "user" , however it
should have been "tweet.user" . Its giving 2 hits now. Thanks for the reply
anyways.