Ok, Thank you got it ! now, i have another question, maybe I should have posted it separately. However, here it is i'm using queryByExample({message : {$word : 'something'}}
This works fine. I want to user queryByExample with term, but $term does not work. And optionnaly, would be nice to use queryByExample with query string like "cat and dog" What's the good approach ? Thank you Le sam. 25 juil. 2015 à 15:23, Erik Hennum <erik.hen...@marklogic.com> a écrit : > 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:* general-boun...@developer.marklogic.com [ > general-boun...@developer.marklogic.com] on behalf of moshir mikael [ > moshir.mik...@gmail.com] > *Sent:* Saturday, July 25, 2015 3:17 AM > *To:* general@developer.marklogic.com > *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 > General@developer.marklogic.com > Manage your subscription at: > http://developer.marklogic.com/mailman/listinfo/general >
_______________________________________________ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general