Use objects in array type and nested objects as root object type


(eugeis) #1

Hello,

a) how can I use a object in array type.

e.g.

folder : {
path : "C:/Windows",
files (should be an array of filetype) :
[
{
name : "File1.txt",
description : "Example file 1"
},
{
name : "File2.txt",
description : "Example file 2"
}
]
}

Files array type should be array of file object type

b) What I have to do, to have the file object type as a root object
type. The folder (root object type) would have nested file root object
type.

Thank You


(Shay Banon) #2

You send a single JSON to be indexed, what you have in the JSON will be
indexed. If you want to search for a specific file name, you can (using your
JSON) use folder.files.name:something (that 'folder.files.name" can be used
anywhere in elasticsearch that accepts a field).

-shay.banon

On Wed, Feb 17, 2010 at 10:36 AM, eugeis eoeisler@googlemail.com wrote:

Hello,

a) how can I use a object in array type.

e.g.

folder : {
path : "C:/Windows",
files (should be an array of filetype) :
[
{
name : "File1.txt",
description : "Example file 1"
},
{
name : "File2.txt",
description : "Example file 2"
}
]
}

Files array type should be array of file object type

b) What I have to do, to have the file object type as a root object
type. The folder (root object type) would have nested file root object
type.

Thank You


(eugeis) #3

Thanks, it works with query "folder.files.name",
but "folder" objects are found, but like expected with all
"files" (matched and unmatched "files").

It is possible to search "folder" and "file" objects? I want something
like

a) curl -XGET http://...:9200/indexname/folder/_search?q=folder.path:xxx
=> "folder" objects are found
b) curl -XGET http://...:9200/indexname/folder/files/_search?q=folder.files.name:xxx
=> "file" objects are found

Therefore I thought that nested "file" object should be also "root"
object.

-eugeis

On 17 Feb., 14:53, Shay Banon shay.ba...@elasticsearch.com wrote:

You send a single JSON to be indexed, what you have in the JSON will be
indexed. If you want to search for a specific file name, you can (using your
JSON) use folder.files.name:something (that 'folder.files.name" can be used
anywhere in elasticsearch that accepts a field).

-shay.banon

On Wed, Feb 17, 2010 at 10:36 AM, eugeis eoeis...@googlemail.com wrote:

Hello,

a) how can I use a object in array type.

e.g.

folder : {
path : "C:/Windows",
files (should be an array of filetype) :
[
{
name : "File1.txt",
description : "Example file 1"
},
{
name : "File2.txt",
description : "Example file 2"
}
]
}

Files array type should be array of file object type

b) What I have to do, to have the file object type as a root object
type. The folder (root object type) would have nested file root object
type.

Thank You


(Shay Banon) #4

You can only navigate from the top level object and downwards. What you can
do, is define the pathType for object mapping as explained here:
http://www.elasticsearch.com/docs/elasticsearch/mapping/object_type/#pathType
.

-shay.banon

On Wed, Feb 17, 2010 at 5:47 PM, eugeis eoeisler@googlemail.com wrote:

Thanks, it works with query "folder.files.name",
but "folder" objects are found, but like expected with all
"files" (matched and unmatched "files").

It is possible to search "folder" and "file" objects? I want something
like

a) curl -XGET http://...:9200/indexname/folder/_search?q=folder.path:xxx
=> "folder" objects are found
b) curl -XGET http://
...:9200/indexname/folder/files/_search?q=folder.files.name:xxx
=> "file" objects are found

Therefore I thought that nested "file" object should be also "root"
object.

-eugeis

On 17 Feb., 14:53, Shay Banon shay.ba...@elasticsearch.com wrote:

You send a single JSON to be indexed, what you have in the JSON will be
indexed. If you want to search for a specific file name, you can (using
your
JSON) use folder.files.name:something (that 'folder.files.name" can be
used
anywhere in elasticsearch that accepts a field).

-shay.banon

On Wed, Feb 17, 2010 at 10:36 AM, eugeis eoeis...@googlemail.com
wrote:

Hello,

a) how can I use a object in array type.

e.g.

folder : {
path : "C:/Windows",
files (should be an array of filetype) :
[
{
name : "File1.txt",
description : "Example file 1"
},
{
name : "File2.txt",
description : "Example file 2"
}
]
}

Files array type should be array of file object type

b) What I have to do, to have the file object type as a root object
type. The folder (root object type) would have nested file root object
type.

Thank You


(system) #5