Hi, Moshir:

One way to solve this problem is to model the data differently:  store each car 
as a separate document and store the agency id in each car document so it is 
easy to retrieve individual cars or all cars for an agency.

An alternative approach is to qualify the documents with the car nodes and 
extract the car nodes. Something like the following (untested) code should work:

db.documents.query(
    qb.where(qb.byExample({size:'small'}))
        .slice(qb.extract(['/cars[size eq "small"]']))
    ).result(...)

For more information about extract, see:

    http://docs.marklogic.com/guide/node-dev/search#id_17648

Extract paths have the same limitations as paths for range indexes:

    http://docs.marklogic.com/guide/admin/range_index#id_40666

That said, modifying the model is usually the better approach in the long run.


Hoping that helps,


Erik Hennum

________________________________
From: [email protected] 
[[email protected]] on behalf of moshir mikael 
[[email protected]]
Sent: Saturday, July 25, 2015 3:17 AM
To: [email protected]
Subject: [MarkLogic Dev General] (no subject)

Hi,

I'm new to marklogic and I'm using node.js client.
I have a very simple structure already loaded to database
{
   id : id of an agency,
   cars : [ an array of cars ]
}
each car in the array has following properties
[
   type : type of car,
   size : size of car
]

I want to use the node.js client api
to query all cars with given type and/or size.

When I use
.db.documents.query(qb.byExample({size:'small'}))
it returns me all agencies with at least one small car (just guessing), but not 
cars

Any help really appreciated !



_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to