Can't get status 200

I installed elasticsearch 5.2.2 on my web server hoping that my problem would be solved but got the same results as 5.0.2.
I can store the data into elasticsearch 5.2.2 but can't get the data and it returns status code 0.
But at least I found out that I can use 5.2.2 with current Javascript API.

Can you run a simple curl command to run a _search query for example?

Did you say at some point that you have a nginx layer?

Yes I can.

curl -XGET 'http://127.31.18.8:9200/users/_search/?pretty'
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "users",
        "_type" : "user",
        "_id" : "John",
        "_score" : 1.0,
        "_source" : {
          "name_suggest" : {
            "input" : "John"
          }
        }
      }
    ]
  }
}

I use nginx as a reverse proxy, but there is no values from elasticsearch.
I don't think nginx is the problem.

server {
    listen       80;
    server_name  example.com;

    location / {
        proxy_pass http://172.31.18.8:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

I hope you are still interested in this post because I have been struggling from this problem for more than 10 days.

Is it a way to put some pressure on my shoulders? If that was your intention, please read the last part of About the Elasticsearch category (Be patient section).

You just opened this one day ago and I think I already answered a lot but you wasted a lot of time by not giving the details I was asking for.

FWIW I wrote my last answer

at 4:45 AM my timezone.

So please, be patient. If you need SLAs on your questions, I can connect you to our sales.

Thanks.

Can you run:

curl -XPOST "http://172.31.18.8:9200/users/_suggest?pretty" -d '{
    "docsuggest": {
      "text": "l",
      "completion": {
        "field": "name_suggest",
        "fuzzy": true
      }
    }
  }'

BTW _suggest endpoint os deprecated. Can you use instead _search as described at https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-suggesters.html

So run something like:

curl -XPOST 'http://172.31.18.8:9200/users/_search?pretty' -H 'Content-Type: application/json' -d'
{
  "suggest" : {
    "docsuggest" : {
      "text" : "l",
      "completion" : {
        "field" : "name_suggest",
        "fuzzy": true
      }
    }
  }
}'

If I sounded disrespectful to you, I'm sorry.
Thank you for taking your time.

The below is the result for running that query.

curl -XPOST 'http://172.31.18.8:9200/users/_search?pretty' -H 'Content-Type: application/json' -d'
> {
>   "suggest" : {
>     "docsuggest" : {
>       "text" : "l",
>       "completion" : {
>         "field" : "name_suggest",
>         "fuzzy": true
>       }
>     }
>   }
> }'
[2017-03-01T07:34:04,414][DEBUG][o.e.a.s.TransportSearchAction] [ip-172-31-18-8] [users][0], node[1thzIqqtR269aDnkaTas6w], [P], s[STARTED], a[id=TSHiN9cJThifHfabH3kReQ]: Failed to execute [SearchRequest{searchType=QUERY_AND_FETCH, indices=[users], indicesOptions=IndicesOptions[id=38, ignore_unavailable=false, allow_no_indices=true, expand_wildcards_open=true, expand_wildcards_closed=false, allow_alisases_to_multiple_indices=true, forbid_closed_indices=true], types=[], routing='null', preference='null', requestCache=false, scroll=null, source={
  "suggest" : {
    "docsuggest" : {
      "text" : "l",
      "completion" : {
        "field" : "name_suggest",
        "fuzzy" : {
          "fuzziness" : 1,
          "transpositions" : true,
          "min_length" : 3,
          "prefix_length" : 1,
          "unicode_aware" : false,
          "max_determinized_states" : 10000
        }
      }
    }
  }
}}]
org.elasticsearch.transport.RemoteTransportException: [ip-172-31-18-8][172.31.18.8:9300][indices:data/read/search[phase/query+fetch]]
Caused by: java.lang.IllegalArgumentException: no mapping found for field [name_suggest]
	at org.elasticsearch.search.suggest.SuggestionBuilder.populateCommonFields(SuggestionBuilder.java:313) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.search.suggest.completion.CompletionSuggestionBuilder.build(CompletionSuggestionBuilder.java:361) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.search.suggest.SuggestBuilder.build(SuggestBuilder.java:178) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.search.SearchService.parseSource(SearchService.java:718) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.search.SearchService.createContext(SearchService.java:540) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:516) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:351) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.action.search.SearchTransportService$9.messageReceived(SearchTransportService.java:322) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.action.search.SearchTransportService$9.messageReceived(SearchTransportService.java:319) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:610) [elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:596) [elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-5.2.2.jar:5.2.2]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_121]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
[2017-03-01T07:34:04,416][DEBUG][o.e.a.s.TransportSearchAction] [ip-172-31-18-8] All shards failed for phase: [query_fetch]
org.elasticsearch.transport.RemoteTransportException: [ip-172-31-18-8][172.31.18.8:9300][indices:data/read/search[phase/query+fetch]]
Caused by: java.lang.IllegalArgumentException: no mapping found for field [name_suggest]
	at org.elasticsearch.search.suggest.SuggestionBuilder.populateCommonFields(SuggestionBuilder.java:313) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.search.suggest.completion.CompletionSuggestionBuilder.build(CompletionSuggestionBuilder.java:361) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.search.suggest.SuggestBuilder.build(SuggestBuilder.java:178) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.search.SearchService.parseSource(SearchService.java:718) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.search.SearchService.createContext(SearchService.java:540) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:516) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:351) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.action.search.SearchTransportService$9.messageReceived(SearchTransportService.java:322) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.action.search.SearchTransportService$9.messageReceived(SearchTransportService.java:319) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:610) [elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:596) [elasticsearch-5.2.2.jar:5.2.2]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-5.2.2.jar:5.2.2]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_121]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "no mapping found for field [name_suggest]"
      }
    ],
    "type" : "search_phase_execution_exception",

    "reason" : "all shards failed",
    "phase" : "query_fetch",
    "grouped" : true,
    "failed_shards" : [
      {
        "shard" : 0,
        "index" : "users",
        "node" : "1thzIqqtR269aDnkaTas6w",
        "reason" : {
          "type" : "illegal_argument_exception",
          "reason" : "no mapping found for field [name_suggest]"
        }
      }
    ],
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "no mapping found for field [name_suggest]"
    }
  },
  "status" : 400
}

So it tells you what is wrong here. name_suggest does not exist in your mapping apparently.

I will look into that but I also realized that when I use _search instead of _suggest, searching fails even in the development environment.

TRACE: 2017-03-01T08:11:50Z
  -> POST http://localhost:9200/users/_search
  {
    "docsuggest": {
      "text": "a",
      "completion": {
        "field": "name_suggest",
        "fuzzy": true
      }
    }
  }
  <- 400
  {
    "error": {
      "root_cause": [
        {
          "type": "parsing_exception",
          "reason": "Unknown key for a START_OBJECT in [docsuggest].",
          "line": 1,
          "col": 15
        }
      ],
      "type": "parsing_exception",
      "reason": "Unknown key for a START_OBJECT in [docsuggest].",
      "line": 1,
      "col": 15
    },
    "status": 400
  }

Incorrect syntax. read again my post

You were right. I input name_suggest as name_sugggest, there was an extra g.
I guess I did make this mistake while I was deleting and creating index to fix the problem.
The mistake wasn't there when I created this post like you can see from my earlier post with curl -XGET '172.31.18.8:9200/users?pretty'

The problem still exists.
It still returns status code 0.

But I was able to run the query successfully this time.

curl -XPOST 'http://172.31.18.8:9200/users/_search?pretty' -H 'Content-Type: application/json' -d'
> {
>   "suggest" : {
>     "docsuggest" : {
>       "text" : "l",
>       "completion" : {
>         "field" : "name_suggest",
>         "fuzzy": true
>       }
>     }
>   }
> }'
{
  "took" : 21,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : 0.0,
    "hits" : [ ]
  },
  "suggest" : {
    "docsuggest" : [
      {
        "text" : "l",
        "offset" : 0,
        "length" : 1,
        "options" : [ ]
      }
    ]
  }
}

Is the syntax of _search same as _suggest?

I feel like I can fix the problem If I find a way to run _search query successfully with my Javascript API in the development environment.

This syntax doesn't work:

 client.search({
   index: "users",
   body: {
     docsuggest: {
       text: search_query,
       completion: {
         field: "name_suggest",
         fuzzy: true
       }
     }
   }
 })

Error

TRACE: 2017-03-01T09:42:31Z
  -> POST http://localhost:9200/users/_search
  {
    "docsuggest": {
      "text": "a",
      "completion": {
        "field": "name_suggest",
        "fuzzy": true
      }
    }
  }
  <- 400
  {
    "error": {
      "root_cause": [
        {
          "type": "parsing_exception",
          "reason": "Unknown key for a START_OBJECT in [docsuggest].",
          "line": 1,
          "col": 15
        }
      ],
      "type": "parsing_exception",
      "reason": "Unknown key for a START_OBJECT in [docsuggest].",
      "line": 1,
      "col": 15
    },
    "status": 400
  }

This syntax works:

client.suggest({
  index: "users",
  body: {
    docsuggest: {
      text: search_query,
      completion: {
        field: "name_suggest",
        fuzzy: true
      }
    }
  }
})

Success

TRACE: 2017-03-01T09:46:10Z
  -> POST http://localhost:9200/users/_suggest
  {
    "docsuggest": {
      "text": "a",
      "completion": {
        "field": "name_suggest",
        "fuzzy": true
      }
    }
  }
  <- 200
  {
    "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
    },
    "docsuggest": [
      {
        "text": "a",
        "offset": 0,
        "length": 1,
        "options": []
      }
    ]
  }

Is the syntax of _search same as _suggest?

No. Again read my post. Can't get status 200 - #28 by dadoonet

I wrote:

curl -XPOST 'http://172.31.18.8:9200/users/_search?pretty' -H 'Content-Type: application/json' -d'
{
  "suggest" : {
    "docsuggest" : {
      "text" : "l",
      "completion" : {
        "field" : "name_suggest",
        "fuzzy": true
      }
    }
  }
}'

I was able to make the _search query work in my development environment.
It can retrieve the data stored and show it on the local site like before.

But the problem still exists in my production environment even after the usage of _search.
It returns status code 0.

Can you run again the curl command and paste the results here?

curl -XPOST 'http://172.31.18.8:9200/users/_search?pretty' -H 'Content-Type: application/json' -d'
> {
>   "suggest" : {
>     "docsuggest" : {
>       "text" : "l",
>       "completion" : {
>         "field" : "name_suggest",
>         "fuzzy": true
>       }
>     }
>   }
> }'
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : 0.0,
    "hits" : [ ]
  },
  "suggest" : {
    "docsuggest" : [
      {
        "text" : "l",
        "offset" : 0,
        "length" : 1,
        "options" : [ ]
      }
    ]
  }
}

I can get results if I use _search query with curl like the following.

curl -XPOST 'http://172.31.18.8:9200/users/_search?pretty' -H 'Content-Type: application/json' -d'
{
  "suggest" : {
    "docsuggest" : {
      "text" : "j",
      "completion" : {
        "field" : "name_suggest",
        "fuzzy": true
      }
    }
  }
> }'
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : 0.0,
    "hits" : [ ]
  },
  "suggest" : {
    "docsuggest" : [
      {
        "text" : "o",
        "offset" : 0,
        "length" : 1,
        "options" : [
          {
            "text" : "John",
            "_index" : "users",
            "_type" : "user",
            "_id" : "John",
            "_score" : 1.0,
            "_source" : {
              "name_suggest" : {
                "input" : "John"
              }
            }
          }
        ]
      }
    ]
  }
}

I just can't get results when I use _search query with Javascript API in the production environment.
Strangely it works in the development environment.

Here we are. This is now a different question IMO.

We prove that elasticsearch is working well.

What does your javascript code is looking like? That said I'm not the right person to comment JS code.

My Javascript code is 100% correct.
Why?
I use the same code as the development.

I guess we couldn't reach a solution.

But I learned a lot from you, so thank you so much for sticking with me.
I will keep working to solve this issue.
If I find a solution, I will post it here.
So if you find anything, please post it here too.

Thanks again.