Hi, Moshir:

>  I think its not possible to do binding search with qbe

Yes, currently, that is a limitation.

You can use structured query with parsed query (or use a
general-purpose parser like Jison to do your own query parsing).

>  I'm sure score ranking is pretty simple

You can use the qb.score() function:

    http://docs.marklogic.com/jsdoc/queryBuilder.html#score

as in:

var query = db
.query(
qb
.where(qb.byExample({ message : {$word : 'message '}}))
.orderBy(qb.sort('createdat', 'ascending'), q.sort(q.score(), 'descending'))
.slice(5, 10)
.calculate(
qb.facet("department", qb.facetOptions('item-frequency','descending'))
)
)


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: Sunday, July 26, 2015 2:36 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] (no subject)

Ok, seems to be configuration in the database.Now, it works !
Last question  :  Still using QBE interface, i want to do
- keyword search city:'Paris'
- (relevance) score ranking

I did not find any example about both of them with node.js (and QBE).
 I think its not possible to do binding search with qbe (which you cannot mix 
with string query and structured query, too bad for me!).

But I'm sure score ranking is pretty simple, but could not find the a proper 
syntax example.
Any example appreciated, here's my test, node.js +QBE:
var query = db
.query(
qb
.where(qb.byExample({ message : {$word : 'message '}}))
.orderBy(qb.sort('createdat', 'ascending'))
.slice(5, 10)
.calculate(
qb.facet("department", qb.facetOptions('item-frequency','descending'))
)
)

How to account for score and optionnaly queries like city:'Paris' ?

Thank you




Le dim. 26 juil. 2015 à 20:54, moshir mikael 
<moshir.mik...@gmail.com<mailto:moshir.mik...@gmail.com>> a écrit :
Thank you.
I have been one issue : doing  qb.byExample({message:{$word : 'mess'}}), this 
founds messages where 'mess' appears'
Doing  qb.byExample({message:{$word : 'MESS'}}), nothing is returned.

What am i doing wrong ?


Le dim. 26 juil. 2015 à 17:02, Erik Hennum 
<erik.hen...@marklogic.com<mailto:erik.hen...@marklogic.com>> a écrit :
Hi, Mikael:

Good to hear that you had success with it.

The value of $word can contain multiple words to search for a phrase.

To search for the word or words anywhere in the document, use $word at the 
top-level as in:

    qb.byExample({$word: 'some phrase'})

You can also use $value when the entire value of a JSON property should be one 
or more words.

    qb.byExample({message:{$value: 'a complete value'}})

In fact, $value is the default operator, so the following query is an 
equivalent shortcut:

    qb.byExample({message:'a complete value'})

You can't, however, use $value at the top level.

To query on a datatyped value, create a range index on the JSON property and 
use $eq, $lt, or one of the other comparison operators.


Hoping that helps,


Erik Hennum

From: 
general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>
 
[general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>]
 on behalf of moshir mikael 
[moshir.mik...@gmail.com<mailto:moshir.mik...@gmail.com>]
Sent: Saturday, July 25, 2015 4:04 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] (no subject)

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<mailto: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<mailto:general-boun...@developer.marklogic.com>
 
[general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>]
 on behalf of moshir mikael 
[moshir.mik...@gmail.com<mailto:moshir.mik...@gmail.com>]
Sent: Saturday, July 25, 2015 3:17 AM
To: general@developer.marklogic.com<mailto: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<mailto:General@developer.marklogic.com>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
General@developer.marklogic.com<mailto: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

Reply via email to