# Search query for a contents in the file

**URL:** <https://discuss.elastic.co/t/search-query-for-a-contents-in-the-file/234110>\
**Category:** Elasticsearch\
**Created:** [May 25, 2020, 9:08am UTC](https://discuss.elastic.co/t/search-query-for-a-contents-in-the-file/234110 "2020-05-25T09:08:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anirudhan](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@Anirudhan](https://discuss.elastic.co/u/Anirudhan)\
**Post date:** [May 25, 2020, 9:08am UTC](https://discuss.elastic.co/t/search-query-for-a-contents-in-the-file/234110/1 "2020-05-25T09:08:50Z")

</div>

I indexing the contents of PDF files using FSCrawler.Now the content of the whole PDF file is stored in the content key in elastic.  
Below is a sample record.

```auto
{
    "content": "\n\n\n WHY TRAVEL INSURANCE?\n\nAn ideal holiday is a balance of planning and enjoyment. Travel Insurance plan plays a pivotal role in the success \n\nof your trip and can make your journey secure and stress free.\n\nThe expenses incurred in a foreign land for availing medical/health care facilities are exorbitant.",
    "meta": {
      "author": "1001562",
      "title": "014725MI_Travel Insurance Jacket & Inserts_HS_For PDF Upload.ai",
      "date": "2015-01-13T00:44:11.000+0000",
      "format": "application/pdf; version=1.5",
      "creator_tool": "PScript5.dll Version 5.2.2",
      "created": "2015-01-13T00:44:11.000+0000"
    },
    "file": {
      "extension": "pdf",
      "content_type": "application/pdf",
      "created": "2018-08-24T11:06:00.000+0000",
      "last_modified": "2018-08-24T11:06:00.000+0000",
      "last_accessed": "2020-05-13T11:09:55.000+0000",
      "indexing_date": "2020-05-13T11:25:12.658+0000",
      "filesize": 761476,
      "filename": "int_travel_brochure.pdf",
      "url": "file:///home/ ***/*** / ***/elk/pdf/*** /int_travel_brochure.pdf"
    },
    "path": {
      "root": "d533120a7a923efe757b567512e5639",
      "virtual": "/int_travel_brochure/int_travel_brochure.pdf",
      "real": "/home/ ****/*** / ***/elk/pdf/*** /int_travel_brochure.pdf"
    }
  }
}

```

I want to fetch 5 lines before and after the exact search term which will be received.  
If journey is inputed i want to fetch 5 lines before and after.Will i be able to increase from 5 to 10 or reduce to 2 lines?

---

<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:** [May 25, 2020, 9:43am UTC](https://discuss.elastic.co/t/search-query-for-a-contents-in-the-file/234110/2 "2020-05-25T09:43:48Z")

</div>

There's no concept of "lines" as per say. You just have here a flat `content` field.

But may be you can solve the use case you are trying to solve by using the [highlighting feature](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-highlighting)?

---

<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:** [June 22, 2020, 9:43am UTC](https://discuss.elastic.co/t/search-query-for-a-contents-in-the-file/234110/3 "2020-06-22T09:43:58Z")

</div>

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