project Utilities / File Location Listing avatar

utilities/file_location_listing#3: Implement Search



Issue Information

Issue Type: issue
Status: closed
Reported By: btasker
Assigned To: btasker

Milestone: proof-of-concept
Created: 28-Dec-23 16:39



Description

Need to build a basic search mechanism to show that the storage format created in utilities/file_location_listing#2 can actually be used.

It's probably prudent to start with an extremely basic search and then go from there



Toggle State Changes

Activity


assigned to @btasker

verified

mentioned in commit 04cbfe623f3934e78d2be8cf2a0a42ffec860911

Commit: 04cbfe623f3934e78d2be8cf2a0a42ffec860911 
Author: B Tasker                            
                            
Date: 2023-12-28T16:38:09.000+00:00 

Message

Implement (very) basic search client (utilities/file_location_listing#3)

+89 -1 (90 lines changed)

The following (rough) implementation allows efficient searching by content type by switching between index types

    srchterm = arg[1]

    search_type = "ALL"
    if len(arg) > 2:
        search_type = arg[2]

    for e in storage.INDEXES[search_type]:
        if srchterm in e['u']:
            # Found a match           
            # Get info for the match
            info = storage.getStoredItem(e['u'])

            print(f"{e['u']} : {info['title']} : {info['last-mod']}")

Valid index types are

  • ALL
  • IMAGE
  • DOC

Anything that's not an image is considered a doc.

Further down the line, may add support for searching by content-type but isn't currently required.

I think it'd probably be prudent to allow searching by title (where available) too

verified

mentioned in commit 254059149f9a3a249b7a4715f3326e1fdccfc994

Commit: 254059149f9a3a249b7a4715f3326e1fdccfc994 
Author: B Tasker                            
                            
Date: 2023-12-28T16:52:09.000+00:00 

Message

Allow searching of titles where available (utilities/file_location_listing#3)

+23 -7 (30 lines changed)