Skip to content
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

WIP: 1080 enable search metadata #1126

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

longshuicy
Copy link
Member

Metadata is a dynamic field, making plain text keyword searches not possible. After experimenting with several approaches without success (detailed below), I have added an additional field metadata_stringify to convert the JSON into a string and cast it to text to enable keyword searches. The original metadata field ispreserved for advanced searches.

To Test:

  1. Drop Volume

  2. Create Metadata Definitions and Metadata:

    • Examples: Abstract, LatLon, DateTime
  3. Keyword Search:

    • Search by metadata key, e.g., "abstract", "latitude"
    • Search by metadata value, e.g., "your metadata value"
    • Test both the search bar on the top bar and the search page
    • Make sure public search functionality
  4. Advanced Search:

    • Use correct syntax and field names
    • Examples:
      • metadata.abstract:marker
      • metadata.latitude:[-70 TO -60]
      • metadata.longitude:[70 TO 90]

Screenshots:

Screenshot1
Screenshot2


Things I Have Tried That Did Not Work:

  1. Updating the Mapping to Cast the Metadata Field to Text

    {
      "mappings": {
        "properties": {
          "metadata": {
            "type": "object",
            "dynamic": true,
            "properties": {
              "*": {
                "type": "text"
              }
            }
          }
        }
      }
    }
  2. Wildcard Search

    curl -X GET "localhost:9200/clowder/_search" -H 'Content-Type: application/json' -d'
    {
      "query": {
        "query_string": {
          "query": "test search",
          "fields": ["metadata.*"]
        }
      }
    }
    '

@longshuicy longshuicy requested review from lmarini, ddey2 and tcnichol June 26, 2024 16:31
@longshuicy longshuicy requested a review from max-zilla as a code owner June 26, 2024 16:31
@longshuicy longshuicy linked an issue Jun 26, 2024 that may be closed by this pull request
@longshuicy longshuicy self-assigned this Jun 26, 2024
@ddey2
Copy link
Member

ddey2 commented Jun 26, 2024

@longshuicy I looked at your approach. It looks okay.

I was wondering if you've tried putting 'default_field' in field_name and "*" in field name value. (look here)

search_query = {
"query": {
"query_string": {
"query": "John OR Title OR Tech",
"default_field": "*"
}
}
}

@longshuicy longshuicy marked this pull request as draft June 27, 2024 20:10
@longshuicy longshuicy changed the title 1080 enable search metadata WIP: 1080 enable search metadata Jun 27, 2024
@tcnichol
Copy link
Contributor

I did populate fake data. Looks like most of the metadata created is lat and lon, so I can verify that lat and lon is working for both basic and advanced search.

Will be checking other types soon.

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.

Search metadata
3 participants