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

Record search history #9647

Merged
merged 18 commits into from
Mar 18, 2023
Merged

Record search history #9647

merged 18 commits into from
Mar 18, 2023

Conversation

MaryJml
Copy link
Contributor

@MaryJml MaryJml commented Mar 4, 2023

Fixes #7906
截屏2023-03-12 18 52 24

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

}

public List<String> getLastSearchHistory(int size) {
List<String> lastSearches = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check if there can some code be shared as a new list type with the FileHistory class? I remember that I worked some time ago with a similar mechanic to limit the max number of entries in the list.

@Siedlerchr Siedlerchr marked this pull request as ready for review March 6, 2023 20:10
@MaryJml MaryJml closed this Mar 6, 2023
@MaryJml MaryJml reopened this Mar 6, 2023
@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Mar 6, 2023
@calixtus calixtus mentioned this pull request Mar 11, 2023
6 tasks
Siedlerchr
Siedlerchr previously approved these changes Mar 11, 2023
@Siedlerchr
Copy link
Member

Tested it locally works fine!

@Siedlerchr Siedlerchr requested a review from calixtus March 11, 2023 15:41
@MaryJml MaryJml requested review from Siedlerchr and removed request for calixtus March 12, 2023 19:23
@HoussemNasri
Copy link
Member

I played around with this feature locally and I noticed that sometimes if I type the search query slowly enough, some of the prefixes of the query are recorded along the actual query. Not having a search button that starts the search task made it hard to select the correct time to perform the search. Currently, JabRef waits for the search box to be idle for 400ms and then performs the query. This is a good time to show the search results because JabRef will feel more interactive, but not so good for adding the query to the history because the user may be unhappy with the results and continue to modify the query, or he may simply be a slow typist like myself :^)

I gave this some thought and these are a few suggestions:

1. Record query when the search box loses focus
Thinking about the search workflow, it would look something like this:

  1. User wants to search for something
  2. User derives a query that matches the pattern he/she has in mind
  3. User types the query and modifies it until it shows the intended results
  4. User selects the entry he/she is searching for

Looking at the workflow above, it seems best to record the search query after step 4: User selects the entry he/she is searching for a.k.a the search box loses focus.

2. Merge recorded search queries with a certain similarity score that were recorded in a close timestamp
If I want to search for 'hello', in the worst case the search history would record all of the prefixes: 'h', 'he', 'hel', 'hell' and 'hello'. We can develop an algorithm that can understand that all of these queries refer to the same query which is 'hello'. We already have a utility class to calculate the similarity between two strings: StringSimilarity, so that's one piece of the problem solved.

After a query is recorded the algorithm would loop through the list of the recorded queries and decides if the new query could be an update to an older query. It goes like this:

  1. The algorithm notices that 'h' and 'he' were recorded 1s apart and they are similar enough so it would remove 'h' and insert 'he'
  2. The algorithm notices that 'he' and 'hel' were recorded 1.5s apart and they are similar enough so it would remove 'he' and insert 'hel'
  3. etc...

@Siedlerchr
Copy link
Member

I would suggest we merge this current as is, and I will move @HoussemNasri comment to a follow up issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: search status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please record search history
5 participants