medic / lucene-query-generator

Generate escaped lucene query strings
Apache License 2.0
16 stars 7 forks source link

Does not handle deep objects #8

Open pszabop opened 7 years ago

pszabop commented 7 years ago

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
garethbowen commented 7 years ago

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

rek72-zz commented 6 years ago

@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 }] }

garethbowen commented 6 years ago

@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.