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

Search for multiple terms appear to be dropping a term #2418

Closed
1 task done
DHMike57 opened this issue Dec 7, 2021 · 4 comments
Closed
1 task done

Search for multiple terms appear to be dropping a term #2418

DHMike57 opened this issue Dec 7, 2021 · 4 comments

Comments

@DHMike57
Copy link
Contributor

DHMike57 commented Dec 7, 2021

Preflight Checklist

  • I have searched the issue tracker for a bug report that matches the one I want to file, without success.

Trilium Version

0.48.5

What operating system are you using?

Other Linux

What is your setup?

Local + server sync

Operating System Version

Linux msata 5.15.3-arch1-1 #1 SMP PREEMPT Thu, 18 Nov 2021 22:23:08 +0000 x86_64 GNU/Linux

Expected Behavior

Some search terms appear to be ignored eg from the demo database search terms "diana #person" and "#person diana" should return the same results

Actual Behavior

#person diana ->

  • Person template (Trilium Demo / My Family Tree)

  • Prince Charles (Trilium Demo / My Family Tree)#dateOfBirth=1948-11-14 ~isPartnerOf=Princess Diana ~isChildOf=Queen Elizabeth II. ~isChildOf=Prince Phillip

  • Prince Phillip (Trilium Demo / My Family Tree)#dateOfBirth=1921-06-10 ~isPartnerOf=Queen Elizabeth II. ~hasChild=Prince Charles

  • Princess Diana (Trilium Demo / My Family Tree)#dateOfBirth=1961-07-01 #dateOfDeath=1997-08-31 ~isPartnerOf=Prince Charles

  • Queen Elizabeth II. (Trilium Demo / My Family Tree)#dateOfBirth=1926-04-21 ~isPartnerOf=Prince Phillip ~hasChild=Prince Charles

diana #person ->

  • Princess Diana (Trilium Demo / My Family Tree)#dateOfBirth=1961-07-01 #dateOfDeath=1997-08-31 ~isPartnerOf=Prince Charles
  • Prince Charles (Trilium Demo / My Family Tree)#dateOfBirth=1948-11-14 ~isPartnerOf=Princess Diana ~isChildOf=Queen Elizabeth II.

Additional Information

search string diana #person -> log:

16:22:54.119 Fulltext tokens: [{"token":"diana","inQuotes":false,"startIndex":0,"endIndex":4}]
16:22:54.119 Expression tokens: [
    {
        "token": "#person",
        "inQuotes": false,
        "startIndex": 7,
        "endIndex": 13
    }
]
16:22:54.120 Expression tree: {
    "name": "AndExp",
    "subExpressions": [
        {
            "name": "PropertyComparisonExp",
            "propertyName": "isArchived",
            "operator": "=",
            "comparedValue": "false"
        },
        {
            "name": "OrExp",
            "subExpressions": [
                {
                    "name": "NoteFlatTextExp",
                    "tokens": [
                        "diana"
                    ]
                },
                {
                    "name": "NoteContentProtectedFulltextExp",
                    "tokens": [
                        "diana"
                    ],
                    "raw": false
                },
                {
                    "name": "NoteContentUnprotectedFulltextExp",
                    "tokens": [
                        "diana"
                    ],
                    "raw": false
                }
            ]
        },
        {
            "name": "AttributeExistsExp",
            "attributeType": "label",
            "attributeName": "person",
            "prefixMatch": false
        }
    ]
}

Search string person #diana -> log

16:25:48.672 Expression tokens: [
    {
        "token": "#person",
        "inQuotes": false,
        "startIndex": 0,
        "endIndex": 6
    },
    {
        "token": "diana",
        "inQuotes": false,
        "startIndex": 9,
        "endIndex": 13
    }
]
16:25:48.672 Expression tree: {
    "name": "AndExp",
    "subExpressions": [
        {
            "name": "PropertyComparisonExp",
            "propertyName": "isArchived",
            "operator": "=",
            "comparedValue": "false"
        },
        {
            "name": "AttributeExistsExp",
            "attributeType": "label",
            "attributeName": "person",
            "prefixMatch": false
        }
    ]
}
@zadam
Copy link
Owner

zadam commented Dec 7, 2021

Some search terms appear to be ignored eg from the demo database search terms "diana #person" and "#person diana" should return the same results

This is not correct, see wiki

The tricky part is to find out where does the fulltext end and where the attribute expression begins. This is done by detecting certain stop-characters/words - all tokens are considered as fulltext before one of #, ~ or note. prefixes are encountered. After that all characters/tokens are understood as attribute expression.

@DHMike57
Copy link
Contributor Author

DHMike57 commented Dec 7, 2021

Sorry, Zadam, if I am being dense about this, but I did read the wiki and took the entry that you indicated to be relevant if you were trying to include hash character in a fulltext search: I am trying to do an implied AND with a string and an attribute, I though that \#person would turn it into literal string. (In the event that my double-quotes were confusing I have edited them out.) Also, in my example above,I don't understand why the diana term appears to be missing from the expression tree,

Is it really the case that searching <string> (implied AND) <attribute> is not the same as <attribute> (implied AND) <string>?

So how should I search for all notes containing the string diana and the attribute #person ?

@zadam
Copy link
Owner

zadam commented Dec 7, 2021

Is it really the case that searching (implied AND) is not the same as (implied AND) ?

Yes, <attribute> (implied AND) <string> is not a valid format, parser won't understand <string> and that's why it won't appear in the expression tree.

Search string has two parts - fulltext part and expression part, they are in that order.

So how should I search for all notes containing the string diana and the attribute #person ?

diana #person is the correct syntax

@DHMike57
Copy link
Contributor Author

DHMike57 commented Dec 7, 2021

Thank you for that: on reading the wiki more carefully I see that now. Sorry for the false alarm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants