# Filtered index alias configuration

**URL:** <https://discuss.elastic.co/t/filtered-index-alias-configuration/8634>\
**Category:** Elasticsearch\
**Created:** [August 4, 2012, 10:24am UTC](https://discuss.elastic.co/t/filtered-index-alias-configuration/8634 "2012-08-04T10:24:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_MacDonald](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matt_macdonald/32/2785_2.png) [@Matt\_MacDonald](https://discuss.elastic.co/u/Matt_MacDonald)\
**Post date:** [August 4, 2012, 10:24am UTC](https://discuss.elastic.co/t/filtered-index-alias-configuration/8634/1 "2012-08-04T10:24:08Z")

</div>

Hi,

Just starting out with Elasticsearch. I am storing Documents and would like  
to create an alias to access them by the municipality\_state field in the  
Document. I have added an alias with a filter to the 'documents' index  
which I would have expected to work and is not.

I created two aliases in the 'documents' index: 'alias1' without a filter  
(working as expected) and 'alias2' with a filter (not working as expected).  
Any thoughts about why or guidance of things to try?

Thanks,  
Matt

_alias1_  
curl -XPOST '[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)' -d '  
{  
"actions" : [  
{ "add" : { "index" : "documents", "alias" : "alias1" } }  
]  
}'

_alias2_  
curl -XPOST '[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)' -d '  
{  
"actions" : [  
{  
"add" : {  
"index" : "documents",  
"alias" : "alias2",  
"filter" : { "term" : { "municipality\_state" : "MA" } }  
}  
}  
]  
}'

_[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)_  
{

- documents:  
{
  - aliases:  
{
    - alias2:  
{
      - filter:  
{
        - term:  
{
          - municipality\_state: "MA"  
}  
}  
},

    - alias1: { }  
}  
}

}

_[http://localhost:9200/documents/document/\_search?q=Water](http://localhost:9200/documents/document/_search?q=Water)_  
{

- took: 6,
- timed\_out: false,
- \_shards:  
{
  - total: 5,
  - successful: 5,
  - failed: 0  
},

- hits:  
{
  - total: 533,
  - max\_score: 0.7214666,
  - hits:  
[

- 
- 

_[http://localhost:9200/alias1/document/\_search?q=Water](http://localhost:9200/alias1/document/_search?q=Water)_  
{

- took: 12,
- timed\_out: false,
- \_shards:  
{
  - total: 5,
  - successful: 5,
  - failed: 0  
},

hits:  
{

- total: 533,
- max\_score: 0.7214666,
- hits:  
[

_[http://localhost:9200/alias2/document/\_search?q=Water](http://localhost:9200/alias2/document/_search?q=Water)_  
{

- took: 2,
- timed\_out: false,
- \_shards:  
{
  - total: 5,
  - successful: 5,
  - failed: 0  
},

- hits:  
{
  - total: 0,
  - max\_score: null,
  - hits: []  
}

}\*  
\*

---

<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 4, 2012, 11:24am UTC](https://discuss.elastic.co/t/filtered-index-alias-configuration/8634/2 "2012-08-04T11:24:35Z")

</div>

I suppose that your field is analyzed so I suggest to filter with lowercase : ma  
But I don't know if ma could be a common english word.  
Just test to see if it works.

Another suggestion is to set your mapping for this field not to be analyzed. I recommand this last approach.

Hope this helps.  
David

--

Le 4 août 2012 à 12:24, Matt MacDonald [matt.macdonald@gmail.com](mailto:matt.macdonald@gmail.com) a écrit :

> Hi,
> 
> Just starting out with Elasticsearch. I am storing Documents and would like to create an alias to access them by the municipality\_state field in the Document. I have added an alias with a filter to the 'documents' index which I would have expected to work and is not.
> 
> I created two aliases in the 'documents' index: 'alias1' without a filter (working as expected) and 'alias2' with a filter (not working as expected). Any thoughts about why or guidance of things to try?
> 
> Thanks,  
> Matt
> 
> alias1  
> curl -XPOST '[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)' -d '  
> {  
> "actions" : [  
> { "add" : { "index" : "documents", "alias" : "alias1" } }  
> ]  
> }'
> 
> alias2  
> curl -XPOST '[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)' -d '  
> {  
> "actions" : [  
> {  
> "add" : {  
> "index" : "documents",  
> "alias" : "alias2",  
> "filter" : { "term" : { "municipality\_state" : "MA" } }  
> }  
> }  
> ]  
> }'
> 
> [http://localhost:9200/\_aliases](http://localhost:9200/_aliases)  
> {  
> documents: {  
> aliases: {  
> alias2: {  
> filter: {  
> term: {  
> municipality\_state: "MA"  
> }  
> }  
> },  
> alias1: { }  
> }  
> }  
> }
> 
> [http://localhost:9200/documents/document/\_search?q=Water](http://localhost:9200/documents/document/_search?q=Water)  
> {  
> took: 6,  
> timed\_out: false,  
> \_shards: {  
> total: 5,  
> successful: 5,  
> failed: 0  
> },  
> hits: {  
> total: 533,  
> max\_score: 0.7214666,  
> hits: [
> 
> [http://localhost:9200/alias1/document/\_search?q=Water](http://localhost:9200/alias1/document/_search?q=Water)  
> {  
> took: 12,  
> timed\_out: false,  
> \_shards: {  
> total: 5,  
> successful: 5,  
> failed: 0  
> },  
> hits: {  
> total: 533,  
> max\_score: 0.7214666,  
> hits: [
> 
> [http://localhost:9200/alias2/document/\_search?q=Water](http://localhost:9200/alias2/document/_search?q=Water)  
> {  
> took: 2,  
> timed\_out: false,  
> \_shards: {  
> total: 5,  
> successful: 5,  
> failed: 0  
> },  
> hits: {  
> total: 0,  
> max\_score: null,  
> hits:   
> }  
> }

---

<div class="post-metadata">

**Author:** ![Matt\_MacDonald](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matt_macdonald/32/2785_2.png) [@Matt\_MacDonald](https://discuss.elastic.co/u/Matt_MacDonald)\
**Post date:** [August 4, 2012, 2:17pm UTC](https://discuss.elastic.co/t/filtered-index-alias-configuration/8634/3 "2012-08-04T14:17:07Z")

</div>

Thank you. Both suggestions worked and I will use the index field mapping  
as you suggest.

{

- municipalities:  
{
  - municipality:  
{
    - properties:  
{
      - full\_name:  
{
        - type: "string"  
},

      - name:  
{
        - type: "string"  
},

      - slug:  
{
        - type: "string"  
},

      - state:  
{
        - type: "string",
        - index: "not\_analyzed"  
}  
}  
}  
}

}

Thanks,  
Matt

On Saturday, August 4, 2012 7:24:35 AM UTC-4, David Pilato wrote:

> I suppose that your field is analyzed so I suggest to filter with  
> lowercase : ma  
> But I don't know if ma could be a common english word.  
> Just test to see if it works.
> 
> Another suggestion is to set your mapping for this field not to be  
> analyzed. I recommand this last approach.
> 
> Hope this helps.  
> David
> 
> --
> 
> Le 4 août 2012 à 12:24, Matt MacDonald [matt.macdonald@gmail.com](mailto:matt.macdonald@gmail.com) a  
> écrit :
> 
> Hi,
> 
> Just starting out with Elasticsearch. I am storing Documents and would  
> like to create an alias to access them by the municipality\_state field in  
> the Document. I have added an alias with a filter to the 'documents' index  
> which I would have expected to work and is not.
> 
> I created two aliases in the 'documents' index: 'alias1' without a filter  
> (working as expected) and 'alias2' with a filter (not working as expected).  
> Any thoughts about why or guidance of things to try?
> 
> Thanks,  
> Matt
> 
> _alias1_  
> curl -XPOST '[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)' -d '  
> {  
> "actions" : [  
> { "add" : { "index" : "documents", "alias" : "alias1" } }  
> ]  
> }'
> 
> _alias2_  
> curl -XPOST '[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)' -d '  
> {  
> "actions" : [  
> {  
> "add" : {  
> "index" : "documents",  
> "alias" : "alias2",  
> "filter" : { "term" : { "municipality\_state" : "MA" } }  
> }  
> }  
> ]  
> }'
> 
> _[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)_  
> {
> 
> - documents:  
> {
> - aliases:  
> {
> - alias2:  
> {
> - filter:  
> {
> - term:  
> {
> - municipality\_state: "MA"  
> }  
> }  
> },
> 
> - alias1: { }  
> }  
> }
> 
> }
> 
> _[http://localhost:9200/documents/document/\_search?q=Water](http://localhost:9200/documents/document/_search?q=Water)_  
> {
> 
> - took: 6,
> - timed\_out: false,
> - \_shards:  
> {
> - total: 5,
> - successful: 5,
> - failed: 0  
> },
> 
> - hits:  
> {
> - total: 533,
> - max\_score: 0.7214666,
> - hits:  
> [
> 
> - 
> - 
> 
> _[http://localhost:9200/alias1/document/\_search?q=Water](http://localhost:9200/alias1/document/_search?q=Water)_  
> {
> 
> - took: 12,
> - timed\_out: false,
> - \_shards:  
> {
> - total: 5,
> - successful: 5,
> - failed: 0  
> },
> 
> hits:  
> {
> 
> - total: 533,
> - max\_score: 0.7214666,
> - hits:  
> [
> 
> _[http://localhost:9200/alias2/document/\_search?q=Water](http://localhost:9200/alias2/document/_search?q=Water)_  
> {
> 
> - took: 2,
> - timed\_out: false,
> - \_shards:  
> {
> - total: 5,
> - successful: 5,
> - failed: 0  
> },
> 
> - hits:  
> {
> - total: 0,
> - max\_score: null,
> - hits:   
> }
> 
> }\*  
> \*

On Saturday, August 4, 2012 7:24:35 AM UTC-4, David Pilato wrote:

> I suppose that your field is analyzed so I suggest to filter with  
> lowercase : ma  
> But I don't know if ma could be a common english word.  
> Just test to see if it works.
> 
> Another suggestion is to set your mapping for this field not to be  
> analyzed. I recommand this last approach.
> 
> Hope this helps.  
> David
> 
> --
> 
> Le 4 août 2012 à 12:24, Matt MacDonald [matt.macdonald@gmail.com](mailto:matt.macdonald@gmail.com) a  
> écrit :
> 
> Hi,
> 
> Just starting out with Elasticsearch. I am storing Documents and would  
> like to create an alias to access them by the municipality\_state field in  
> the Document. I have added an alias with a filter to the 'documents' index  
> which I would have expected to work and is not.
> 
> I created two aliases in the 'documents' index: 'alias1' without a filter  
> (working as expected) and 'alias2' with a filter (not working as expected).  
> Any thoughts about why or guidance of things to try?
> 
> Thanks,  
> Matt
> 
> _alias1_  
> curl -XPOST '[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)' -d '  
> {  
> "actions" : [  
> { "add" : { "index" : "documents", "alias" : "alias1" } }  
> ]  
> }'
> 
> _alias2_  
> curl -XPOST '[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)' -d '  
> {  
> "actions" : [  
> {  
> "add" : {  
> "index" : "documents",  
> "alias" : "alias2",  
> "filter" : { "term" : { "municipality\_state" : "MA" } }  
> }  
> }  
> ]  
> }'
> 
> _[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)_  
> {
> 
> - documents:  
> {
> - aliases:  
> {
> - alias2:  
> {
> - filter:  
> {
> - term:  
> {
> - municipality\_state: "MA"  
> }  
> }  
> },
> 
> - alias1: { }  
> }  
> }
> 
> }
> 
> _[http://localhost:9200/documents/document/\_search?q=Water](http://localhost:9200/documents/document/_search?q=Water)_  
> {
> 
> - took: 6,
> - timed\_out: false,
> - \_shards:  
> {
> - total: 5,
> - successful: 5,
> - failed: 0  
> },
> 
> - hits:  
> {
> - total: 533,
> - max\_score: 0.7214666,
> - hits:  
> [
> 
> - 
> - 
> 
> _[http://localhost:9200/alias1/document/\_search?q=Water](http://localhost:9200/alias1/document/_search?q=Water)_  
> {
> 
> - took: 12,
> - timed\_out: false,
> - \_shards:  
> {
> - total: 5,
> - successful: 5,
> - failed: 0  
> },
> 
> hits:  
> {
> 
> - total: 533,
> - max\_score: 0.7214666,
> - hits:  
> [
> 
> _[http://localhost:9200/alias2/document/\_search?q=Water](http://localhost:9200/alias2/document/_search?q=Water)_  
> {
> 
> - took: 2,
> - timed\_out: false,
> - \_shards:  
> {
> - total: 5,
> - successful: 5,
> - failed: 0  
> },
> 
> - hits:  
> {
> - total: 0,
> - max\_score: null,
> - hits:   
> }
> 
> }\*  
> \*

On Saturday, August 4, 2012 7:24:35 AM UTC-4, David Pilato wrote:

> I suppose that your field is analyzed so I suggest to filter with  
> lowercase : ma  
> But I don't know if ma could be a common english word.  
> Just test to see if it works.
> 
> Another suggestion is to set your mapping for this field not to be  
> analyzed. I recommand this last approach.
> 
> Hope this helps.  
> David
> 
> --
> 
> Le 4 août 2012 à 12:24, Matt MacDonald [matt.macdonald@gmail.com](mailto:matt.macdonald@gmail.com) a  
> écrit :
> 
> Hi,
> 
> Just starting out with Elasticsearch. I am storing Documents and would  
> like to create an alias to access them by the municipality\_state field in  
> the Document. I have added an alias with a filter to the 'documents' index  
> which I would have expected to work and is not.
> 
> I created two aliases in the 'documents' index: 'alias1' without a filter  
> (working as expected) and 'alias2' with a filter (not working as expected).  
> Any thoughts about why or guidance of things to try?
> 
> Thanks,  
> Matt
> 
> _alias1_  
> curl -XPOST '[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)' -d '  
> {  
> "actions" : [  
> { "add" : { "index" : "documents", "alias" : "alias1" } }  
> ]  
> }'
> 
> _alias2_  
> curl -XPOST '[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)' -d '  
> {  
> "actions" : [  
> {  
> "add" : {  
> "index" : "documents",  
> "alias" : "alias2",  
> "filter" : { "term" : { "municipality\_state" : "MA" } }  
> }  
> }  
> ]  
> }'
> 
> _[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)_  
> {
> 
> - documents:  
> {
> - aliases:  
> {
> - alias2:  
> {
> - filter:  
> {
> - term:  
> {
> - municipality\_state: "MA"  
> }  
> }  
> },
> 
> - alias1: { }  
> }  
> }
> 
> }
> 
> _[http://localhost:9200/documents/document/\_search?q=Water](http://localhost:9200/documents/document/_search?q=Water)_  
> {
> 
> - took: 6,
> - timed\_out: false,
> - \_shards:  
> {
> - total: 5,
> - successful: 5,
> - failed: 0  
> },
> 
> - hits:  
> {
> - total: 533,
> - max\_score: 0.7214666,
> - hits:  
> [
> 
> - 
> - 
> 
> _[http://localhost:9200/alias1/document/\_search?q=Water](http://localhost:9200/alias1/document/_search?q=Water)_  
> {
> 
> - took: 12,
> - timed\_out: false,
> - \_shards:  
> {
> - total: 5,
> - successful: 5,
> - failed: 0  
> },
> 
> hits:  
> {
> 
> - total: 533,
> - max\_score: 0.7214666,
> - hits:  
> [
> 
> _[http://localhost:9200/alias2/document/\_search?q=Water](http://localhost:9200/alias2/document/_search?q=Water)_  
> {
> 
> - took: 2,
> - timed\_out: false,
> - \_shards:  
> {
> - total: 5,
> - successful: 5,
> - failed: 0  
> },
> 
> - hits:  
> {
> - total: 0,
> - max\_score: null,
> - hits:   
> }
> 
> }\*  
> \*

---

<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:17am UTC](https://discuss.elastic.co/t/filtered-index-alias-configuration/8634/4 "2017-07-06T03:17:41Z")

</div>


