# Full Text Search query

**URL:** <https://discuss.elastic.co/t/full-text-search-query/158853>\
**Category:** Elasticsearch\
**Created:** [November 30, 2018, 5:58am UTC](https://discuss.elastic.co/t/full-text-search-query/158853 "2018-11-30T05:58:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tapaswi](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@Tapaswi](https://discuss.elastic.co/u/Tapaswi)\
**Post date:** [November 30, 2018, 5:58am UTC](https://discuss.elastic.co/t/full-text-search-query/158853/1 "2018-11-30T05:58:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 30, 2018, 6:10am UTC](https://discuss.elastic.co/t/full-text-search-query/158853/2 "2018-11-30T06:10:12Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). 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.

---

<div class="post-metadata">

**Author:** ![Tapaswi](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@Tapaswi](https://discuss.elastic.co/u/Tapaswi)\
**Post date:** [November 30, 2018, 6:36am UTC](https://discuss.elastic.co/t/full-text-search-query/158853/3 "2018-11-30T06:36:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 30, 2018, 7:32am UTC](https://discuss.elastic.co/t/full-text-search-query/158853/4 "2018-11-30T07:32:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tapaswi](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@Tapaswi](https://discuss.elastic.co/u/Tapaswi)\
**Post date:** [November 30, 2018, 10:38am UTC](https://discuss.elastic.co/t/full-text-search-query/158853/5 "2018-11-30T10:38:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 30, 2018, 4:48pm UTC](https://discuss.elastic.co/t/full-text-search-query/158853/6 "2018-11-30T16:48:23Z")

</div>

As I said previously, without a reproduction script (read again [Full Text Search query](https://discuss.elastic.co/t/full-text-search-query/158853/2?u=dadoonet)) 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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 28, 2018, 4:48pm UTC](https://discuss.elastic.co/t/full-text-search-query/158853/7 "2018-12-28T16:48:27Z")

</div>

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