Skip to content

Add natural language search #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

vgeorge
Copy link
Member

@vgeorge vgeorge commented Jun 13, 2025

This adds a natural language search UI to the STAC Browser, if an API endpoint is provided.

Based on the work from @sunu available at sunu#1.

Changes included:

  • Added a Natural Language search form and logic
  • Added a README section on how to enable the feature

To run this locally:

npm start -- --open --catalogUrl="https://earth-search.aws.element84.com/v1/" --semanticSearchApiUrl="https://stac-semantic-search.labs.sunu.in"

Suggested next steps:

  • Improve error handling (for API errors)
  • Clean up console.log debug statements

@j08lue @sunu @AliceR what else do you think we need to change or implement for the demo?

ps: I set the target of this PR to a branch on this repo, but we can change it if we decide to push upstream.

@j08lue
Copy link
Member

j08lue commented Jun 13, 2025

Nice! I'll spin this up to review the UI/UX. 🙏

Once we think it's ok, it would be great to deploy this somewhere (ds.io or Netlify or so), so we can show it to people (e.g. at LPS 23-27 June.

@sunu
Copy link
Member

sunu commented Jun 16, 2025

@vgeorge This is exciting! I was wondering if we could add one more thing -- would it be possible to use the return_search_params_only flag on our API so we can get just the STAC search parameters and then query the STAC API directly for items? Do you think that might be easy to implement?

Our current endpoint doesn’t handle pagination when returning items, so it would be fantastic if we could leverage the STAC API’s pagination features instead.

@j08lue
Copy link
Member

j08lue commented Jun 16, 2025

Agree with @sunu - it would be great to let the client (STAC Browser) handle the actual STAC query and processing of results.

UI/UX-wise, the map works nicely for validating the geo-coded area of interest - it would be great to show the AOI on the map as well, on top of the scenes and their footprints.

As a user, I would like some more info about what happened and what query parameters the chatbot came up with.

We should surface the explanation that the LLM app returns. We should also provide an option for the user to show the CQL2 query that the query was translated into.

Cloud-free Sentinel-2 scenes over Berlin, Germany in June 2024

        "explanation": "Considering the following collections:\n- sentinel-2-l2a: This collection specifically contains Sentinel-2 imagery, which is required for the user's query.\n- hls2-s30: This collection includes Sentinel-2 data for analysis and has a high temporal frequency fitting the user's needs.\n- io-lulc: Derived from Sentinel-2 imagery, this collection could provide relevant land cover data for Berlin.\n- io-lulc-annual-v02: This collection offers annual land cover data based on Sentinel-2 imagery, likely containing relevant information for Berlin."

image

@vgeorge
Copy link
Member Author

vgeorge commented Jun 18, 2025

I added changes to address your feedback:

  • Merged natural query input into search form (will display if feature is enabled)
  • Display query explanation returned by the API under the input
  • Display query intersect geojson on the map
  • Populate remaining fields with query results

Populating the spatial extend field is a bit more complex. Currently it only accepts bounding boxes. In order to use the geojson from the natural search I think we need to change its behaviour to a toggle with three options:

  • No spatial filter
  • Bounding box filter: existing workflow, but displays the bounding box on the map after querying
  • Natural search intersect: auto-selected after a natural search is finished, displays the natural search geojson on the map

This is ready for another review.

Preview:

Screenshot 2025-06-18 at 14 44 28

Copy link
Member

@j08lue j08lue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UI looks great now, @vgeorge, thanks for addressing all my requests to make it easier for users to understand the submitted query and what happened.

I see you are not using return_search_params_only yet, but relying on the semantic search app to return the items. It probably takes a larger rework to change this - but we need to, please.

A few issues, probably due to the search API response:

  1. The list of collections under the search bar has duplicates
    image
  2. The query against https://stac-semantic-search.labs.sunu.in returns very weird results for me, geocoding-wise. Marrakesh, Morocco, even London, UK shows up somewhere in the ocean.
  3. I appreciate the warning that submitting a query will reset the form, @vgeorge . Could we clear the form right away when the user hits the Search button? That way, it is clear that this data is obsolete and that it gets replaced once the (new) query returns
    image

image

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.

3 participants