SpringDataElasticsearchDevs / spring-data-elasticsearch

Spring Data implementation for ElasticSearch
63 stars 26 forks source link

Exception occurred in assertion #22

Closed yl3w closed 11 years ago

yl3w commented 11 years ago

An mvn clean package on this repository includes an example that fails. it is infact amongst the first examples I tried and might be a user error.

The exception occurs in spring-data-elasticsearch, the results from ES itself are what I would expect.

https://github.com/maddalab/sample-es-application

mohsinh commented 11 years ago

Thanks you so much for rectifying it !

Agree documentation part of spring data elasticsearch is wrong for your test case. I will change that for sure.

It will return a single Object as internally it will call queryForObject of ElasticsearchTemplate class. If you want multiple records please call for Page request.

Initially we implemented support for List but it is not feasible as you could have 1000s of record and you don’t want to load all of them in a list at a time. Hence List is replaced by Page request. And you can easily get List by using getContent() method of Page.

I have added two test cases for detail information , you can always fork sample application project and add more test cases and play around !

Test

I will talk to my team about repository methods that return List with Pageable request. If it will be feasible then it will be available soon

also you are using Client in your test case to delete data from index, which is not required as repository has deleteAll() default method to do that(see test case for more detail)

Hope that helps Let me know if you still have doubt

mohsinh commented 11 years ago

Support for repository and template to have methods which will return List is added...

please see below test cases for more information...

Test