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 api常常不灵 #9

Closed
wujita01 opened this issue Jan 19, 2022 · 5 comments
Closed

search api常常不灵 #9

wujita01 opened this issue Jan 19, 2022 · 5 comments

Comments

@wujita01
Copy link

seach api 时灵时不灵。不知道是什么原因。您这边测试一直都正常吗。

@wujita01
Copy link
Author

确认了搜索的关键字在Joplin里是有的。但是还是会返回[],表示为空。我用的是terminal版本。

@marph91
Copy link
Owner

marph91 commented Jan 19, 2022

I could only translate it online, since I don't speak any asian language. As far as I understood, the search API doesn't work for you sometimes. Could you give some example strings that don't work? I can imagine there might be problems with encoding some characters.

There is one testcase for special characters. It works for the example strings, but could be more extensive.

Also please note that the search considers only notes by default. If you want to search other things, you have to specify the type argument. For example api.search(query="xyz", type="tag") to search tags.

@wujita01
Copy link
Author

wujita01 commented Jan 25, 2022

I have use api.search(query="xyz", type="note") to search it . I find if I create a note use the api, and in a long time ,I can't search any thing about the new note even I have try joplin sync(old notes can be searched properly). but when I try tomorrow ,I can search just use the api.search(query="xyz", type="note") ,I don't modify any command but I can search it now? I can't understand why?

by the way, I use the terminal version of joplin, does it matter?

@marph91
Copy link
Owner

marph91 commented Jan 28, 2022

There was already some issue about the search being slow. I will link, if I find it again. I can reproduce a delay between creating and searching the note of 5-10 seconds with the desktop version. There shouldn't be a big difference between terminal and desktop version.

Testcase:

    def test_note_search(self):
        self.api.add_notebook()
        self.api.add_note(title="test_title", body="test_content")
        for iteration in range(10):
            print(f"{iteration=}", self.api.search(query="test_content"))
            time.sleep(1)

Output:

$ python -m unittest test.test_api.Search.test_note_search
iteration=0 {'items': [], 'has_more': False}
iteration=1 {'items': [], 'has_more': False}
iteration=2 {'items': [], 'has_more': False}
iteration=3 {'items': [], 'has_more': False}
iteration=4 {'items': [], 'has_more': False}
iteration=5 {'items': [], 'has_more': False}
iteration=6 {'items': [], 'has_more': False}
iteration=7 {'items': [{'id': '8fc4b281aafc4aebb8d5b4051d93abfb', 'parent_id': '73cdaee3a814482d8d4acc64cd25813a', 'title': 'test_title'}], 'has_more': False}
iteration=8 {'items': [{'id': '8fc4b281aafc4aebb8d5b4051d93abfb', 'parent_id': '73cdaee3a814482d8d4acc64cd25813a', 'title': 'test_title'}], 'has_more': False}
iteration=9 {'items': [{'id': '8fc4b281aafc4aebb8d5b4051d93abfb', 'parent_id': '73cdaee3a814482d8d4acc64cd25813a', 'title': 'test_title'}], 'has_more': False}
.
----------------------------------------------------------------------
Ran 1 test in 19.247s

OK

So in this case, the search returns the correct results only after 8 seconds. It might be more for larger or more notes. I assume this is a limitation of the Joplin search itself rather than the API. Could you check if the notes are searchable after ~10 seconds?

@marph91
Copy link
Owner

marph91 commented Apr 15, 2022

Hi @wujita01, could you resolve the issue?

@marph91 marph91 closed this as completed Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants