Full Text Search query

My full-text search is not working properly and also it's taking too much time to execute elasticsearch query I am using following code to get the data from elasticsearch using java.

PageRequest pageRequest = (PageRequest)pageable;
SearchRequest searchRequest = new SearchRequest("jankalyan_new");
searchRequest.types("consumer_cases");
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
QueryStringQueryBuilder queryStringQueryBuilder =
QueryBuilders.queryStringQuery(query);
searchSourceBuilder.query(queryStringQueryBuilder);
searchSourceBuilder.from((int)pageRequest.getOffset());
searchSourceBuilder.size(pageRequest.getPageSize());
searchSourceBuilder.sort(new FieldSortBuilder("company_info.total_cases").order(SortOrder.DESC));
searchRequest.source(searchSourceBuilder);

where pageable and query is the parameter coming from the front end and Jankalyan_new is my index name.

If I type Bangalore in the search text field it is giving other address data on the top and after that Bangalore address data is coming which is wrong. could you please suggest me is I am going correctly? if correct then why its giving wrong result and taking too much time. And If I am going wrong then could you please suggest me a better solution on the same?

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

I have missed this line from code
searchResponse = restHighLevelClient.search(searchRequest);

using this response I am returning a string from rest API and It's simple text search query where I have added sort filter also to get records in sorted order.
My problem is getting wrong result and taking too much time for execution.

I don't understand what your problem is. So I'm afraid I can not help.

you can go through www.jankalyan.online website there is search field we have provided. We want data from elastic search who will match with the text entered in search input text field. I have written service in java for the same. Above code is present in that but its not working correctly means getting wrong result. I have given bangalore search text example before.

As I said previously, without a reproduction script (read again Full Text Search query) I won't be able to help.

Once we have figured out what is happening with simple REST queries, we can think about the Java code related to this.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.