lucene-query-generator icon indicating copy to clipboard operation
lucene-query-generator copied to clipboard

Does not handle deep objects

Open pszabop opened this issue 9 years ago • 3 comments

If I want to compose a query on an object in Lucene with the following structure, I'm unable to create a query for story.author.name:

story {
    author {
        id
        name
    }
}

I get this kind of error:

str.replace is not a function  at Object.format .... line 18 ....

It appears to me from reading the code that this module cannot handle any deep objects at all. If the object in Lucene is not completely flat there does appear to be an obvious way to construct a query.

Here's the attempt to build the query:

var query = {};
query.$operator = 'AND';
query.$operands = []
query.$operands.push({ story: { author : { name: 'Twain' } } } )
console.log(generator.convert(query));  // this emits the error shown above

pszabop avatar Mar 10 '17 20:03 pszabop

@pszabop Hi! What is the desired lucene query string?

garethbowen avatar Mar 13 '17 08:03 garethbowen

@garethbowen: to reply to your previous question (as I am running into same issue) the end result would look like this...

projects:(title:'abc')

This lucene searches on the Document with this structure... { name:string, projects:[ { id:int, title:string }] }

rek72-zz avatar Sep 12 '17 15:09 rek72-zz

@rek72 @pszabop Can you check out the linked commits and let me know if that looks right? I couldn't find any documentation for nested queries so I was guessing a little but it seems to work.

garethbowen avatar Sep 14 '17 07:09 garethbowen