INCATools / INCATools/ontology-access-kit
Optimize horned-owl text search for large local OWL ontologies
- Dominant language
- Python
- Stars
- 198
- Forks
- 35
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 1
Description
Context
After adding `basic_search()` support to the py-horned-owl-backed `funowl` adapter, text queries work again, but they are still slow on large ontologies because the implementation scans all entities.
Reproduction
```bash
uv run runoak -I ofn -i ~/repos/cell-ontology/src/ontology/cl-edit.owl info neuron
```
Observed behavior
- The command eventually returns `CL:0000540 ! neuron`, but only after walking the ontology.
- The command keeps scanning for additional matches even after finding the exact label hit.
- ID lookups such as `uv run runoak -I ofn -i ~/repos/cell-ontology/src/ontology/cl-edit.owl info CL:0000540` are much faster.
Expected behavior
- Exact label and identifier lookups should be much closer to ID lookup latency on large local OWL files.
- Partial search should remain supported, but exact search should avoid an O(n) full scan when possible.
Implementation note
The current behavior comes from `src/oaklib/implementations/funowl/funowl_implementation.py::basic_search`. Likely fixes include:
- build a lightweight in-memory index for labels, aliases, and xrefs
- add a fast path for exact identifier and exact label search
- allow CLI query paths to stop early when an exact match is sufficient
Contributor guide
Research direction
Start by reproducing the exact label and identifier queries with the provided uv run runoak commands, then inspect basic_search in src/oaklib/implementations/funowl/funowl_implementation.py. Compare exact and partial searches on a large local OWL file. Done means exact label and identifier lookups approach ID lookup latency while partial search remains supported and exact matches do not continue scanning unnecessarily.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100