update script to handle aliases exact and partial
This commit is contained in:
parent
d916c6925b
commit
4453fd1daa
1 changed files with 13 additions and 4 deletions
|
|
@ -51,6 +51,15 @@ def cmd_get(args):
|
|||
coll, client = get_collection()
|
||||
query = {}
|
||||
if args.name:
|
||||
# Try exact match first (name or any alias), then regex fallback
|
||||
name_lower = args.name.lower()
|
||||
exact = coll.find_one({"$or": [
|
||||
{"name": name_lower},
|
||||
{"aliases": name_lower},
|
||||
]})
|
||||
if exact:
|
||||
query["_id"] = exact["_id"]
|
||||
else:
|
||||
query["$or"] = [
|
||||
{"name": {"$regex": args.name, "$options": "i"}},
|
||||
{"aliases": {"$regex": args.name, "$options": "i"}},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue