Filtered index alias configuration

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' -d '
{
"actions" : [
{ "add" : { "index" : "documents", "alias" : "alias1" } }
]
}'

alias2
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions" : [
{
"add" : {
"index" : "documents",
"alias" : "alias2",
"filter" : { "term" : { "municipality_state" : "MA" } }
}
}
]
}'

http://localhost:9200/_aliases
{

  • documents:
    {
    • aliases:
      {
      • alias2:
        {
        • filter:
          {
          • term:
            {
            • municipality_state: "MA"
              }
              }
              },
      • alias1: { }
        }
        }

}

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
{

  • 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
{

  • took: 2,
  • timed_out: false,
  • _shards:
    {
    • total: 5,
    • successful: 5,
    • failed: 0
      },
  • hits:
    {
    • total: 0,
    • max_score: null,
    • hits: [ ]
      }

}*
*

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 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' -d '
{
"actions" : [
{ "add" : { "index" : "documents", "alias" : "alias1" } }
]
}'

alias2
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions" : [
{
"add" : {
"index" : "documents",
"alias" : "alias2",
"filter" : { "term" : { "municipality_state" : "MA" } }
}
}
]
}'

http://localhost:9200/_aliases
{
documents: {
aliases: {
alias2: {
filter: {
term: {
municipality_state: "MA"
}
}
},
alias1: { }
}
}
}

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
{
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
{
took: 2,
timed_out: false,
_shards: {
total: 5,
successful: 5,
failed: 0
},
hits: {
total: 0,
max_score: null,
hits:
}
}

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 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' -d '
{
"actions" : [
{ "add" : { "index" : "documents", "alias" : "alias1" } }
]
}'

alias2
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions" : [
{
"add" : {
"index" : "documents",
"alias" : "alias2",
"filter" : { "term" : { "municipality_state" : "MA" } }
}
}
]
}'

http://localhost:9200/_aliases
{

  • documents:
    {
    • aliases:
      {
      • alias2:
        {
        • filter:
          {
          • term:
            {
            • municipality_state: "MA"
              }
              }
              },
      • alias1: { }
        }
        }

}

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
{

  • 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
{

  • 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 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' -d '
{
"actions" : [
{ "add" : { "index" : "documents", "alias" : "alias1" } }
]
}'

alias2
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions" : [
{
"add" : {
"index" : "documents",
"alias" : "alias2",
"filter" : { "term" : { "municipality_state" : "MA" } }
}
}
]
}'

http://localhost:9200/_aliases
{

  • documents:
    {
    • aliases:
      {
      • alias2:
        {
        • filter:
          {
          • term:
            {
            • municipality_state: "MA"
              }
              }
              },
      • alias1: { }
        }
        }

}

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
{

  • 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
{

  • 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 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' -d '
{
"actions" : [
{ "add" : { "index" : "documents", "alias" : "alias1" } }
]
}'

alias2
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions" : [
{
"add" : {
"index" : "documents",
"alias" : "alias2",
"filter" : { "term" : { "municipality_state" : "MA" } }
}
}
]
}'

http://localhost:9200/_aliases
{

  • documents:
    {
    • aliases:
      {
      • alias2:
        {
        • filter:
          {
          • term:
            {
            • municipality_state: "MA"
              }
              }
              },
      • alias1: { }
        }
        }

}

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
{

  • 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
{

  • took: 2,
  • timed_out: false,
  • _shards:
    {
    • total: 5,
    • successful: 5,
    • failed: 0
      },
  • hits:
    {
    • total: 0,
    • max_score: null,
    • hits:
      }

}*
*