# How highlight a text without index it

**URL:** <https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476>\
**Category:** Elasticsearch\
**Created:** [July 20, 2019, 10:35am UTC](https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476 "2019-07-20T10:35:55Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmad\_Hashemi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmad_hashemi/32/43328_2.png) [@ahmad\_Hashemi](https://discuss.elastic.co/u/ahmad_Hashemi)\
**Post date:** [July 20, 2019, 10:35am UTC](https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476/1 "2019-07-20T10:35:55Z")

</div>

Is there any way to highlight a text without indexing it? such as lucene highlighter that get text and query as a parameter an highlight it.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 21, 2019, 1:56am UTC](https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476/2 "2019-07-21T01:56:26Z")

</div>

No, I do not think that is possible. What is your use case? What exactly are you looking to achieve?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [July 21, 2019, 7:54pm UTC](https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476/3 "2019-07-21T19:54:42Z")

</div>

Check out the percolate api - you can store queries and then run JSON against them. Supports highlighting.

---

<div class="post-metadata">

**Author:** ![ahmad\_Hashemi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmad_hashemi/32/43328_2.png) [@ahmad\_Hashemi](https://discuss.elastic.co/u/ahmad_Hashemi)\
**Post date:** [July 22, 2019, 7:24am UTC](https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476/4 "2019-07-22T07:24:14Z")

</div>

Christian thanks for your answer.  
Exactly I want to use elasticsearch in my desktop application locally (not in a server). For security, data shouldn't store in elastic. data of documents is encrypted and stored in a sqlite database. So i need to highlight documents after searching.

---

<div class="post-metadata">

**Author:** ![ahmad\_Hashemi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmad_hashemi/32/43328_2.png) [@ahmad\_Hashemi](https://discuss.elastic.co/u/ahmad_Hashemi)\
**Post date:** [July 22, 2019, 7:28am UTC](https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476/5 "2019-07-22T07:28:04Z")

</div>

Thanks for your answer.  
But i think elasticsearch need a \_highlight endpoint as \_analyze endpoint.  
Lucene support this and i think elastic can do it.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 22, 2019, 7:34am UTC](https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476/6 "2019-07-22T07:34:14Z")

</div>

Then why use Elasticsearch? Why not highlight in your application so it matches what you searched for?

---

<div class="post-metadata">

**Author:** ![ahmad\_Hashemi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmad_hashemi/32/43328_2.png) [@ahmad\_Hashemi](https://discuss.elastic.co/u/ahmad_Hashemi)\
**Post date:** [July 22, 2019, 8:30am UTC](https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476/7 "2019-07-22T08:30:42Z")

</div>

I index my documents and search in them by elasticsearch and i want to highlight results by it. i don't have any highlighter that can highlight my documents by my query an custom analyzer.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [July 22, 2019, 8:33am UTC](https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476/8 "2019-07-22T08:33:23Z")

</div>

> [@ahmad\_Hashemi](#):
>
> i don't have any highlighter that can highlight my documents by my query an custom analyzer.

I'm not sure why that would be the case. Can you explain further what is broken?

---

<div class="post-metadata">

**Author:** ![ahmad\_Hashemi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmad_hashemi/32/43328_2.png) [@ahmad\_Hashemi](https://discuss.elastic.co/u/ahmad_Hashemi)\
**Post date:** [July 22, 2019, 8:44am UTC](https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476/9 "2019-07-22T08:44:01Z")

</div>

When i dont store my data in elasticsearch and disable \_souce field because of security then elasticsearch can not highlight results. so i must highlight them my self or find a way that elasticsearch can highlight a text by my query and my analyzer.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [July 22, 2019, 8:53am UTC](https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476/10 "2019-07-22T08:53:59Z")

</div>

> [@ahmad\_Hashemi](#):
>
> and disable \_souce field because of security

OK - I expect you're on your own here then.  
Disabling source gives a reduced experience for a variety of reasons (highlighting, reindexing).  
We do offer security features that protect documents so that is not normally the reason we'd see people resort to disabling source (usually it is people seeking to have absolutely minimal storage space).

---

<div class="post-metadata">

**Author:** ![ahmad\_Hashemi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmad_hashemi/32/43328_2.png) [@ahmad\_Hashemi](https://discuss.elastic.co/u/ahmad_Hashemi)\
**Post date:** [July 23, 2019, 6:54am UTC](https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476/11 "2019-07-23T06:54:29Z")

</div>

> [@Mark\_Harwood](#):
>
> We do offer security features that protect documents

How can i protect my data when my indices are in the user's system. As I said my indices aren't in a server. My application works offline and elasticsearch is installed on the user system.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [July 23, 2019, 8:48am UTC](https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476/12 "2019-07-23T08:48:31Z")

</div>

Sorry, I don't understand the distinctions you're drawing.  
Elasticsearch security prevents access to the content of elasticsearch documents held in an elasticsearch index.  
If you haven't enabled elasticsearch security, disabling source does not prevent attackers from discovering what was in the original documents via other means.

---

<div class="post-metadata">

**Author:** ![ahmad\_Hashemi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmad_hashemi/32/43328_2.png) [@ahmad\_Hashemi](https://discuss.elastic.co/u/ahmad_Hashemi)\
**Post date:** [July 24, 2019, 7:55am UTC](https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476/13 "2019-07-24T07:55:50Z")

</div>

I think that all Elasticsearch security features are efficient when the elasicsearch is installed in a server and data(indices) is not in the client( If I'm wrong, correct it). But in my case, data(indices) are available to the user and he can install an elasticsearch and get data by a simple query. So I disable source so that it could not easily get source of documents and only can search in them.  
Is there any way that I can protect source of data(indices) when data is available? for example data encryption or other ways.  
Thank you for your patience.

---

<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:** [August 21, 2019, 7:55am UTC](https://discuss.elastic.co/t/how-highlight-a-text-without-index-it/191476/14 "2019-08-21T07:55:54Z")

</div>

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