# Excluding terms from highlighting

**URL:** <https://discuss.elastic.co/t/excluding-terms-from-highlighting/8770>\
**Category:** Elasticsearch\
**Created:** [August 17, 2012, 3:06pm UTC](https://discuss.elastic.co/t/excluding-terms-from-highlighting/8770 "2012-08-17T15:06:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Beau\_Keogh](https://avatars.discourse-cdn.com/v4/letter/b/848f3c/32.png) [@Beau\_Keogh](https://discuss.elastic.co/u/Beau_Keogh)\
**Post date:** [August 17, 2012, 3:06pm UTC](https://discuss.elastic.co/t/excluding-terms-from-highlighting/8770/1 "2012-08-17T15:06:43Z")

</div>

Hi, I have an index with documents which contain a "companyid" and some  
other text fields. The companyid refers to our clients' id number. So in  
our application when presenting results to each client we need to construct  
our search to include both the criteria they enter AND their clientid  
number so that we're only showing them their records. We also have  
highlighting turned on. The issue is that if the client id is "1", the  
number 1 gets highlighted in the snippets along with the other valid  
keywords.

So, is there a way to exclude a term from highlighting? Or, is our approach  
even the best way? We're using couchdb river to index a single couchdb  
database and it's working well. I'd rather not get into having a db/index  
for each client...

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:** [August 17, 2012, 4:08pm UTC](https://discuss.elastic.co/t/excluding-terms-from-highlighting/8770/2 "2012-08-17T16:08:24Z")

</div>

I strongly think that it's better to isolate clients by index. There is no additional cost in term of storage or performance.

You can also give a look to aliases:

> **[Elastic — The Search AI Company](https://www.elastic.co)**
>
> Power insights and outcomes with The Elastic Search AI Platform. See into your data and find answers that matter with enterprise solutions designed to help you accelerate time to insight. Try Elastic ...

It should help with filtered aliases.

## HTH

David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 17 août 2012 à 17:06, Beau Keogh [beaukeogh@gmail.com](mailto:beaukeogh@gmail.com) a écrit :

> Hi, I have an index with documents which contain a "companyid" and some other text fields. The companyid refers to our clients' id number. So in our application when presenting results to each client we need to construct our search to include both the criteria they enter AND their clientid number so that we're only showing them their records. We also have highlighting turned on. The issue is that if the client id is "1", the number 1 gets highlighted in the snippets along with the other valid keywords.
> 
> So, is there a way to exclude a term from highlighting? Or, is our approach even the best way? We're using couchdb river to index a single couchdb database and it's working well. I'd rather not get into having a db/index for each client...
> 
> ## Thanks in advance

--

---

<div class="post-metadata">

**Author:** ![Beau\_Keogh](https://avatars.discourse-cdn.com/v4/letter/b/848f3c/32.png) [@Beau\_Keogh](https://discuss.elastic.co/u/Beau_Keogh)\
**Post date:** [August 17, 2012, 7:40pm UTC](https://discuss.elastic.co/t/excluding-terms-from-highlighting/8770/3 "2012-08-17T19:40:19Z")

</div>

Thanks David,

we chose to use a single index based on feedback from Shay (  
[https://groups.google.com/forum/?fromgroups#!searchin/elasticsearch/beau$20keogh/elasticsearch/HcoeGoPXJ\_U/bM5SpYnrH1wJ](https://groups.google.com/forum/?fromgroups#!searchin/elasticsearch/beau$20keogh/elasticsearch/HcoeGoPXJ_U/bM5SpYnrH1wJ)  
,  
[Redirecting to Google Groups](https://groups.google.com/forum/?fromgroups#!searchin/elasticsearch/data$20flow/elasticsearch/49q-_AgQCp8/MRol0t9asEcJ%5B1-25%5D)).  
Also since we're indexing couchdb I thought it would be less of a headache  
to maintain one couchdb-\>es river vs potentially 1000's.

But, the alias idea sounds like it might be the right track, in tandem with  
routing. But I'm trying to figure out if/how that would work. From what  
I've digested thus far I think the following might work:

- One large index with 50-100 shards
- setup a mapping with the \_routing field and set the path to our companyid  
field
- create an alias for each company and set the routing value to the  
companyid and also set the filter to the appropriate companyid

Any input/feedback is much appreciated!

On Friday, August 17, 2012 11:08:24 AM UTC-5, David Pilato wrote:

> I strongly think that it's better to isolate clients by index. There is no  
> additional cost in term of storage or performance.
> 
> You can also give a look to aliases:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases.html)
> 
> It should help with filtered aliases.
> 
> ## HTH
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 17 août 2012 à 17:06, Beau Keogh \<[beau...@gmail.com](mailto:beau...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> Hi, I have an index with documents which contain a "companyid" and some  
> other text fields. The companyid refers to our clients' id number. So in  
> our application when presenting results to each client we need to construct  
> our search to include both the criteria they enter AND their clientid  
> number so that we're only showing them their records. We also have  
> highlighting turned on. The issue is that if the client id is "1", the  
> number 1 gets highlighted in the snippets along with the other valid  
> keywords.
> 
> So, is there a way to exclude a term from highlighting? Or, is our  
> approach even the best way? We're using couchdb river to index a single  
> couchdb database and it's working well. I'd rather not get into having a  
> db/index for each client...
> 
> Thanks in advance
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [August 18, 2012, 10:12am UTC](https://discuss.elastic.co/t/excluding-terms-from-highlighting/8770/4 "2012-08-18T10:12:56Z")

</div>

Hi David

On Fri, 2012-08-17 at 18:08 +0200, David Pilato wrote:

> I strongly think that it's better to isolate clients by index. There  
> is no additional cost in term of storage or performance.

It depends how big each client is. If you have 10,000 small clients,  
you're going to struggle to have one real index per client.

I'd say much better to use filtered aliases instead.

clint

> 

--

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [August 18, 2012, 10:14am UTC](https://discuss.elastic.co/t/excluding-terms-from-highlighting/8770/5 "2012-08-18T10:14:19Z")

</div>

On Fri, 2012-08-17 at 08:06 -0700, Beau Keogh wrote:

> Hi, I have an index with documents which contain a "companyid" and  
> some other text fields. The companyid refers to our clients' id  
> number. So in our application when presenting results to each client  
> we need to construct our search to include both the criteria they  
> enter AND their clientid number so that we're only showing them their  
> records. We also have highlighting turned on. The issue is that if the  
> client id is "1", the number 1 gets highlighted in the snippets along  
> with the other valid keywords.

Don't include the companyid in the \_all field. Or, better, just search  
on the fields you really want to search on, instead of the \_all field

clint

--

---

<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:** [July 6, 2017, 3:15am UTC](https://discuss.elastic.co/t/excluding-terms-from-highlighting/8770/6 "2017-07-06T03:15:58Z")

</div>


