{"error":{"root_cause":[{"type":"parsing_exception","reason":"Unknown key for a START_OBJECT in [try].","line":1,"col":8}],"type":"parsing_exception","reason":"Unknown key for a START_OBJECT in [try].","line":1,"col":8},"status":400}

<?php

namespace App\Http\Controllers;

use Elasticsearch\Client;
use Illuminate\Http\Request;

class AjaxController extends Controller
{
public function getPage()
	{
		return view('suggest');
}

private $client;

public function __construct(Client $client)
{
$this->client = $client;
}

public function suggest(Request $request)
{
$data = $request->all();

$params = [
    'index' => 'blueocean',
    'body' => [
        'try' => [
            'text' => 'god',
            'completion' => [ 'field' => 'Provider' ]
        ]
    ]
];


dump($data);

$response = $this->client->search($params);
dump($response);
}

}

I'm getting {"error":{"root_cause":[{"type":"parsing_exception","reason":"Unknown key for a START_OBJECT in [try].","line":1,"col":8}],"type":"parsing_exception","reason":"Unknown key for a START_OBJECT in [try].","line":1,"col":8},"status":400} error.
Why?
Any help?

Hello,

At first sight looks like you query is invalid:

I don't think try is a valid key (is what the error log is telling you) and the rest of que query does also not look good to me . What are you trying to get ? How your mapping is ?

Thanks for reply sir.
I'm going to implement autocomplete feature with this with no success. If possible, tell me what I'm doing wrong.

Mapping:

    curl -X PUT "localhost:9200/hosting" -H 'Content-Type: application/json' -d'
    {
        "settings": {
            "number_of_shards": 1, 
            "analysis": {
                "filter": {
                    "autocomplete_filter": { 
                        "type":     "edge_ngram",
                        "min_gram": 1,
                        "max_gram": 20
                    }
                },
                "analyzer": {
                    "autocomplete": {
                        "type":      "custom",
                        "tokenizer": "standard",
                        "filter": [
                            "lowercase",
                            "autocomplete_filter" 
                        ]
                    }
                }
            }
        },

    "mappings" : 
    {
        "plans" : 
        {
            "properties" : 
            {
            	"Provider":
            	{
            		"type": "text",
					"analyzer" : "standard"
            	},

            	"Name":
            	{
            		"type": "text",
					"analyzer" : "standard"
            	},


            	"UpdatedAt":
            	{
            		"type": "text",
					"analyzer" : "standard"
            	}
            }
        }
    }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.