findAllByTimeStampBetweenAndStoreIn(Long startTime, Long endTime, List<String> Store) not working

Viewed 43

I'm trying to fetch data between given timeStamp and in the given list of stores from Elastic Index, but when I'm doing it by looping through the listOfStores it's working fine and I'm getting the data for that particular store

 listOfStores.forEach( i -> {
            List<InStoreDemographicIndex> inStoreDemographicIndices =
                inStoreSearchRepo.findAllByTimeStampBetweenAndStore(startTime, endTime, i)); 
}) 

But at the same time when I'm trying,

List<InStoreDemographicIndex> inStoreDemographicIndices = inStoreSearchRepo
.findAllByTimeStampBetweenAndStoreIn(startTime, endTime, listOfStores);

and passing only one Store at a time, this query is not working and in result I'm getting data for all the stores, even though I'm passing only one Store.

1 Answers

Well, it took a long time to get the answer to this problem, but finally got my answer on spring data ElasticSearch under 8.2.2 Query creation.

enter image description here

The above query was not working because of the variable Store used in the repository method,

In Service Class:

List inStoreDemographicIndices = inStoreSearchRepo .findAllByTimeStampBetweenAndStoreIn(startTime, endTime, listOfStores);

OLD inStoreSearchRepo Repository:

List<InStoreDemographicIndex> findAllByTimeStampBetweenAndStoreIn(Long startTime, Long endTime,  List<String> Store);

Instead of Store in should be the stores.

Correct inStoreSearchRepo Repository:

findAllByTimeStampBetweenAndStoreIn(Long startTime, Long endTime, List stores);

So in conclusion:

suppose if the field name is store,

your repository method should be List<Object> findAllByStoreIn(List<String> stores);

Thanks..!!

Related