openstreetmap / openstreetmap-website

The Rails application that powers OpenStreetMap
https://www.openstreetmap.org/
GNU General Public License v2.0
2.2k stars 910 forks source link

Add search box to diaries page #3289

Open jidanni opened 3 years ago

jidanni commented 3 years ago

On https://www.openstreetmap.org/diary add a box to search, for e.g.,

mvexel commented 2 years ago

I just wrote about this on my diary! This would be a lovely feature to have.

mvexel commented 2 years ago

There was an interesting suggestion in the comments section of my diary entry. It seems that search engines are pretty capable to handle a diary-specific search given the right syntax. I am guessing most users coming across the User Diaries page do not know how to compose a search command like this. So I suggested (copying from the diary comment):

Perhaps there is a way to create a search box that parses whatever the user enters and redirects (new tab) to search engine results. So a user would enter, for example, openstreetcam and this would open a tab with https://duckduckgo.com/?q=site%3Aopenstreetmap.org%2Fuser+diary+%22openstreetcam%22.

As an added bonus, it would expose more users to a privacy-centered search engine.

Would that be a feasible implementation of this?

mvexel commented 2 years ago

Someone suggested documenting search strategies using existing external search engine syntax, so I took the User Diaries OSM wiki page (which was a redirect) and added some hopefully relevant content there.

kcne commented 2 months ago

Progress on Diary Search Implementation

Here's a summary of the search methods we've explored for the diaries page:

  1. PostgreSQL LIKE Search:

    • Method: Used the LIKE operator for basic text searching.
    • Results: Fast but lacks relevance ranking.
    • Code:
      entries = entries.where("title LIKE :query OR body LIKE :query", query: search_query)
  2. pg_search Gem:

    • Method: Added full-text search with the pg_search gem.
    • Results: Provides relevance ranking and partial word matching but is slow with 600,000+ entries.
    • Code:

      include PgSearch::Model
      pg_search_scope :search_by_title_and_body,
                   against: [:title, :body],
                   using: { tsearch: { prefix: true } }
      
      entries = entries.search_by_title_and_body(params[:search])
  3. Trigram Indexes:

    • Next Step: Considering pg_trgm for faster searches with some relevance ranking. This adds complexity with new database migrations.
  4. External Search Engines:

    • Consideration: Redirecting searches to external engines like DuckDuckGo. Downsides include delayed indexing and less control.

Main Questions

Your feedback will help determine the best approach.

danieldegroot2 commented 2 months ago

Ref Is there way to search users' diaries in OSM?, OSM Help Forum (OSQA) - November 17, 2015 (and similar comment in reply by mmd-osm)

Use cases; i.e. users looking for user-created guides besides wiki. Related use cases based on https://github.com/openstreetmap/openstreetmap-website/issues/1362#issuecomment-259432522

search/filter diary entries from friends. moderate diary entries. search/filter diary entries near users changesets. etc etc.

(sidenote: searching by date range is not mentioned in browser search engine example on earlier mentioned wiki page.)