arrays - Dealing with Categories in documents for elasticsearch -



arrays - Dealing with Categories in documents for elasticsearch -

been wrestling while , need help.

i have document array in php looks this

array("title"=>"some title", "description" => "short description", "categories" => array ( array("id" => "1", "name" => "category 1"), array("id" => "5", "name" => "category 5"), array("id" => "55", "name" => "category 55"), ) );

so have document has many categories assigned. ultimate aim homecoming documents contain specific category id.

i have setup mappings, , documents beingness index ok. have tried both "nested" type of mapping category, no mapping @ all, , "lists" type did not work @ error on creation of mappings.

sample of how set "lists"

array( '_source' => array( 'enabled' => true ), 'properties' => array( 'title' => array( 'type' => 'string', 'analyzer' => 'standard' ), 'description' => array( 'type' => 'string', 'analyzer' => 'standard' ), 'categories' => array( "type" => "lists", "properties"=> array( "id" => array("type"=> "integer" ), "name" => array( "type"=> "string" ), ), ), ) );

and completeness, how set "nested"

array( '_source' => array( 'enabled' => true ), 'properties' => array( 'title' => array( 'type' => 'string', 'analyzer' => 'standard' ), 'description' => array( 'type' => 'string', 'analyzer' => 'standard' ), 'categories' => array( "type" => "nested", "properties"=> array( "id" => array("type"=> "integer" ), "name" => array( "type"=> "string" ), ), ), ) );

when trying create search against nested mappings, tells me

queryparsingexception: [nested] nested object under path [categories] not of nested type

when trying create nested search against united nations mapped set of categories (defaulting scheme finds) returns same error above.

my questions are:

what mapping should setup these array of categories ?

given "match_all" query, filter (and how) should utilize single category?

so much in advance takes time read this, allow lone answer. i'm hopeful can help.

the reply pretty simple. had misread documentation , has added object type mapping requests did not need there.

'categories' => array( "type" => "lists", "properties"=> array( "id" => array("type"=> "integer" ), "name" => array( "type"=> "string" ), ), ),

should have been

'categories' => array( "properties"=> array( "id" => array("type"=> "integer" ), "name" => array( "type"=> "string" ), ), ),

the array type not need defined type, assumed array. 1 time removed, loads mapping properly.

now on searching....

arrays elasticsearch categories

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -