0

I came across a problem where I needed to update the stopwords on an index, which was specifying the english analyzer as the default analyzer. Typically, the analyzers are specified in the settings for the index:

{
  "twitter": {
    "settings": {
      "index": {
        "creation_date": "1469465586110",
        "analysis": {
          "filter": {
            "lowercaseFilter": {
              "type": "lowercase"
            }
          },
          "analyzer": {
            "default": {
              "type": "english"
            },
...

So, the analyzers are located at <index name>.settings.index.analysis.analyzer

To update the analyzer, I ran these commands:

curl -XPOST "http://localhost:9200/twitter/_close" && \
curl -XPUT "http://localhost:9200/twitter/_settings" -d'
{
    "analysis": {
        "analyzer": {
            "default": {
                "type": "english",
                "stopwords": "_none_"
            }
        }
    }
}' && \
curl -XPOST "http://localhost:9200/twitter/_open"

After running those commands, I verified that the default analyzer was analyzing text, and keeping all stopwords.

However, when I use the Jest client, now the settings look like this, and the analysis isn't happening properly (note how the analysis settings are under the "members" property now):

{
  "twitter": {
    "settings": {
      "index": {
        "members": {
          "analysis": {
            "analyzer": {
              "default": {
                "type": "english",
                "stopwords": "_none_"
              },

I've stepped through the code and everything looks in order: intellij debug Jest UpdateSettings payload

Nkosi
  • 235,767
  • 35
  • 427
  • 472
BrDaHa
  • 5,138
  • 5
  • 32
  • 47

1 Answers1

0

I figured it out. So by running:

sudo tcpflow -p -c -i lo0 port 9200 2>/dev/null | grep -oE '.*(GET|POST|PUT|DELETE) .*_dev.*' -A30

I could see that the JsonObject I was sending was including the members field, which is where Gson's JsonObject stores the objects inside itself. Since I was passing this raw object into Jest's UpdateSettings builder, it was being serialized in a way I didn't expect (including the members field), and being sent to elasticsearch that way. I solved the problem by calling the JsonObject's toString() method and passing that to the UpdateSettings Builder

BrDaHa
  • 5,138
  • 5
  • 32
  • 47