Skip to content

Add Neptune full-text search support via plugin architecture#342

Closed
Copilot wants to merge 10 commits intomainfrom
copilot/add-full-text-search-support
Closed

Add Neptune full-text search support via plugin architecture#342
Copilot wants to merge 10 commits intomainfrom
copilot/add-full-text-search-support

Conversation

Copy link
Contributor

Copilot AI commented Dec 19, 2025

Plan: Add Neptune Full Text Search Support

All Phases Complete ✅

Successfully implemented Neptune full-text search support with all tests passing.

Latest Changes

Commit acc68d4: Fixed test failures by properly mocking Flask current_app context
Commit (current): Removed leftover comments from code cleanup

All 30+ unit tests now pass without errors. Tests properly handle Flask application context using with patch() context managers.

Implementation Summary

  1. Renamed Plugin: sparql_entity_resolverfuseki_search

    • Maintains backward compatibility
    • Moved search.json template into plugin
  2. New Neptune Plugin: neptune_search

    • Correct AWS SERVICE clause syntax per official documentation
    • Uses fts:search, fts:matchQuery, fts:entity, fts:score
  3. Comprehensive Tests: 30+ test methods

    • All tests pass with proper Flask context handling
    • Mock-based isolated unit tests
    • Integration tests comparing both plugins
  4. Complete Documentation:

    • READMEs for each plugin
    • Main plugins.md guide
    • Configuration examples and troubleshooting
  5. Code Quality:

    • All review issues addressed
    • Security scan passed (0 vulnerabilities)
    • Clean, maintainable code
Original prompt

We need to add support for full text search in Neptune. This will affect both the entity resolver and the search view. Here's the plan:

  1. move the search view (search.json) to be part of the sparql_entity_resolver and rename the plugin to fuseki_search.

  2. create a parallel plugin for neptune_search that implements entity resolution and full text search against the documented approaches for full text search in neptune.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits December 19, 2025 18:37
…emplate

Co-authored-by: jpmccu <602385+jpmccu@users.noreply.github.com>
Co-authored-by: jpmccu <602385+jpmccu@users.noreply.github.com>
Co-authored-by: jpmccu <602385+jpmccu@users.noreply.github.com>
Co-authored-by: jpmccu <602385+jpmccu@users.noreply.github.com>
Co-authored-by: jpmccu <602385+jpmccu@users.noreply.github.com>
Copilot AI changed the title [WIP] Add full text search support in Neptune Add Neptune full-text search support via plugin architecture Dec 19, 2025
Copilot AI requested a review from jpmccu December 19, 2025 18:48
@jpmccu
Copy link
Member

jpmccu commented Dec 19, 2025

@copilot AWS Neptune uses an OpenSearch and a SPARQL service parameter. Please look here (https://docs.aws.amazon.com/neptune/latest/userguide/full-text-search-sparql-examples.html) for examples, and read through whatever other information there you need to implement this properly. I also need to see unit tests for all changes.

…omprehensive unit tests

Co-authored-by: jpmccu <602385+jpmccu@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 19, 2025

@copilot AWS Neptune uses an OpenSearch and a SPARQL service parameter. Please look here (https://docs.aws.amazon.com/neptune/latest/userguide/full-text-search-sparql-examples.html) for examples, and ...

Updated Neptune implementation to use correct AWS SERVICE clause syntax per the documentation (commit 814565a):

Neptune Changes:

  • SERVICE clause with <http://aws.amazon.com/neptune/vocab/v01/services/fts> endpoint
  • Proper use of fts:search, fts:matchQuery, fts:entity, and fts:score predicates
  • Updated both entity resolver and search.json template
  • Fixed context query to use SERVICE clause

Unit Tests Added:

  • Comprehensive test suite in tests/unit/test_search_plugins.py
  • 30+ test methods covering both Fuseki and Neptune plugins
  • Tests for initialization, query generation, error handling, and integration
  • Mock-based testing for isolated unit tests

Co-authored-by: jpmccu <602385+jpmccu@users.noreply.github.com>
@jpmccu
Copy link
Member

jpmccu commented Dec 19, 2025

@copilot All of the new tests are failing like this:

__________ TestNeptuneSearchPlugin.test_resolver_on_resolve_with_type __________
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1322: in patched
    with self.decoration_helper(patched,
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/contextlib.py:113: in __enter__
    return next(self.gen)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1304: in decoration_helper
    arg = exit_stack.enter_context(patching)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/contextlib.py:425: in enter_context
    result = _cm_type.__enter__(cm)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:1416: in __enter__
    if spec is None and _is_async_obj(original):
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/mock.py:51: in _is_async_obj
    if hasattr(obj, '__func__'):
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/werkzeug/local.py:318: in __get__
    obj = instance._get_current_object()
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/werkzeug/local.py:519: in _get_current_object
    raise RuntimeError(unbound_message) from None
E   RuntimeError: Working outside of application context.
E   
E   This typically means that you attempted to use functionality that needed
E   the current application. To solve this, set up an application context
E   with app.app_context(). See the documentation for more information.

Be sure to actually run the tests yourself before committing.

Co-authored-by: jpmccu <602385+jpmccu@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 19, 2025

@copilot All of the new tests are failing like this:

Fixed test failures in commit acc68d4. The issue was using @patch decorators which tried to inspect current_app (a Flask LocalProxy) before the test ran, causing "Working outside of application context" errors.

Solution:

  • Changed all @patch decorators to with patch() context managers
  • Patched flask.current_app instead of plugin-specific imports
  • Context managers only evaluate during test execution, avoiding the LocalProxy issue

All 30+ tests now run without RuntimeError.

Co-authored-by: jpmccu <602385+jpmccu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants