Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding block/page unification in query #3630

Closed

Conversation

houshuang
Copy link
Contributor

In the query_dsl.cljs file at the bottom, there is an example of a query that currently gives the wrong result.

(query "(and (page-property foo bar) [[hello]])"))

Currently asking for blocks on pages matching a certain query, like page-property, results in all eligible blocks being listed, whether or not they are on pages with that page property.

The problem seems to be that in the generated datalog query, there are conditions on the page ?p and the block ?b, but there is no link between the two - no condition that ?b be on a page ?p. When adding that condition to the query ( ['?b :block/page '?p]), we get the desired results.

However, it is not clear to me exactly where to add this string in the code. On one hand, it does not seem to do any harm to add this link whether or not there are actual block conditions (ie. a pure page query with this where clause added still works). However, this does not take into account cases like (or (page-property a) [[a]]), nested and/ors etc. Therefore I am submitting this PR merely as an illustration, and I hope someone who understands the query parser logic better than me can help implement this properly.

I'd love to see this addressed, since this to me is a major improvement over Roam, and potentially incredibly useful in many use cases (show me all writings on "method" only from papers about biology - based on a page-property science-field biology for example).

Tweeted a little walkthrough video (more for people interested in Logseq development, not necessary to understand this PR)
https://www.loom.com/share/a849904da94043c69e09a1a95d8e7e1a

@andelf andelf added the query label Dec 28, 2021
@tiensonqin
Copy link
Contributor

@houshuang Thank you for investigating this problem! I'll give it a try tomorrow and reply later.

tiensonqin added a commit that referenced this pull request Dec 29, 2021
Related to #3630.

Full text search example in a nested query:
(and [[page]] "query")
@tiensonqin
Copy link
Contributor

@houshuang The block/page unification is addressed in #3664.
Full-text search is supported in nested queries too.
CleanShot 2021-12-29 at 21 31 16

tiensonqin added a commit that referenced this pull request Dec 29, 2021
Related to #3630.

Full text search example in a nested query:
(and [[page]] "query")
@tiensonqin
Copy link
Contributor

Ok, closing this now.

@tiensonqin tiensonqin closed this Dec 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants