# Keyword search using Elastic search

**URL:** <https://discuss.elastic.co/t/keyword-search-using-elastic-search/204271>\
**Category:** Elasticsearch\
**Created:** [October 18, 2019, 7:15pm UTC](https://discuss.elastic.co/t/keyword-search-using-elastic-search/204271 "2019-10-18T19:15:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dharmil25](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@dharmil25](https://discuss.elastic.co/u/dharmil25)\
**Post date:** [October 18, 2019, 7:15pm UTC](https://discuss.elastic.co/t/keyword-search-using-elastic-search/204271/1 "2019-10-18T19:15:35Z")

</div>

Hi,

I am new to Elasticsearch and I am trying to achieve a text search functionality using Elasticsearch. I have over 100 documents and every document has lines starting with timestamp notations.  
Eg.  
00:00:00 - 00:01:00 This is first line  
00:01:01 - 00:02:30 This is second line  
00:02:30 - 00:03:45 This is third line  
...  
And so on.  
I am splitting each of these lines into different paragraphs and performing a text search over the documents.

Now, I want to search by keyword wherein 1 or more keywords would be defined for let's say lines between timestamp 00:00:00 - 00:05:00. So based on keyword search, the entire data from 00:00:00 - 00:05:00 should be returned. As in all the lines in between these timestamps should be returned based on keyword search.

Can you please help me understand how to achieve this functionality using Elasticsearch?

Thanks in advance!!

---

<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:** [October 19, 2019, 9:30am UTC](https://discuss.elastic.co/t/keyword-search-using-elastic-search/204271/2 "2019-10-19T09:30:54Z")

</div>

Welcome!

What are the JSON document looking like?  
I mean, are you splitting the line in multiple fields like `start_date`, `end_date` and `message`?

If you could share a sample JSON document that could be helpful to guide you.

Another question. Do you have a full timestamp like with the date or only the hour of the day?

---

<div class="post-metadata">

**Author:** ![dharmil25](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@dharmil25](https://discuss.elastic.co/u/dharmil25)\
**Post date:** [October 19, 2019, 6:10pm UTC](https://discuss.elastic.co/t/keyword-search-using-elastic-search/204271/4 "2019-10-19T18:10:47Z")

</div>

Hi David,

We are getting text documents which are only timestamp and text detail. These files are actual speech text, hence contain timestamp (time without date) and space separated text.

So, I am splitting my data into time and message fields.  
So my document having line 1 as:

00:00:00 - 00:01:00 This is first line

is split into 2 fields i.e.

```
time: 00:00:00 - 00:01:00 
message: This is first line  

```

This is exactly how I have the data in my documents.

> Keyword: cricket, football
> 
> 00:00:00 - 00:01:00 This is first line
> 
> 00:01:01 - 00:02:30 This is second line
> 
> 00:02:30 - 00:03:45 This is third line
> 
> 00:03:45 - 00:05:00 This is fourth line
> 
> Keyword: tennis
> 
> 00:05:00 - 00:06:55 This is fifth line
> 
> 00:06:55 - 00:07:45 This is sixth line
> 
> ...

So, I have 1 or more keywords(cricket, football) for a paragraph within time range 00:00:00 - 00:05:00 and based on keyword search(cricket) the entire paragraph should be returned.

Also, I am not sure how keyword will be stored, will it be separate table? how to define the relation?  
We need to search text on basis of keyword and return data within the time range.

Thanks!!

---

<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:** [November 16, 2019, 6:10pm UTC](https://discuss.elastic.co/t/keyword-search-using-elastic-search/204271/5 "2019-11-16T18:10:59Z")

</div>

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