Is there any way to implement JOINS in Lucene?
相关问题
- SQL join to get the cartesian product of 2 columns
- JCR-SQL - contains function doesn't escape spe
- Query self-join with Sequelize, including related
- Multiple (left, cross?) JOINs in MS Access
- Adding Inner join and where clause to INSERT INTO
相关文章
- Solr - _version_ field must exist in schema and be
- SQL Server 2008: Joining results of STORED PROCEDU
- Join two tables in MySQL, returning just one row f
- Oracle USING clause best practice
- Redshift table update with join
- Join datatables using column names stored in varia
- Deleting using LEFT JOIN
- How to make these JOIN queries?
You can do a generic join by hand - run two searches, get all results (instead of top N), sort them on your join key and intersect two ordered lists. But that's gonna thrash your heap real hard (if the lists even fit in it).
There are possible optimizations, but under very specific conditions.
I.e. - you do a self-join, and only use (random access)
Filters
for filtering, noQueries
. Then you can manually iterate terms on your two join fields (in parallel), intersect docId lists for each term, filter them - and here's your join.There's an approach handling a popular use-case of simple parent-child relationships with relatively small numer of children per-document - https://issues.apache.org/jira/browse/LUCENE-2454
Unlike the flattening method mentioned by @ntziolis, this approach correctly handles cases like: have a number of resumes, each with multiple work_experience children, and try finding someone who worked at company NNN in year YYY. If simply flattened, you'll get back resumes for people that worked for NNN in any year & worked somewhere in year YYY.
An alternative for handling simple parent-child cases is to flatten your doc, indeed, but ensure values for different children are separated by a big posIncrement gap, and then use
SpanNear
query to prevent your several subqueries from matching across children. There was a few-years old LinkedIn presentation about this, but I failed to find it.Here is an example Numere provides an easy way to extract analytical data from Lucene indexes
Result:
... continue