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

Chore/solr9 upgrade #1406

Merged
merged 11 commits into from
Jul 21, 2023
Merged

Chore/solr9 upgrade #1406

merged 11 commits into from
Jul 21, 2023

Conversation

blms
Copy link
Contributor

@blms blms commented Jun 26, 2023

No description provided.

@blms
Copy link
Contributor Author

blms commented Jun 26, 2023

Running into an issue getting any results back from keyword queries, seems to be a problem with the query construction format, but I don’t see any documentation of a change or deprecation.

These all fail...
keyword_search_qf = "{!type=edismax qf=$keyword_qf pf=$keyword_pf v=$keyword_query}"

def keyword_search(self, search_term):
    search = self.search(self.keyword_search_qf).raw_query_parameters(
        keyword_query=self._search_term_cleanup(search_term)
    )
keyword_search_qf = "{!type=edismax qf=description_en_bigram pf=description_en_bigram v=$keyword_query}"

def keyword_search(self, search_term):
    search = self.search(self.keyword_search_qf).raw_query_parameters(
        keyword_query=self._search_term_cleanup(search_term)
    )
keyword_search_qf = "{!type=edismax v=$keyword_query}"

def keyword_search(self, search_term):
    self.search(self.keyword_search_qf).raw_query_parameters(
        keyword_query=self._search_term_cleanup(search_term),
        qf="$keyword_qf",
        pf="$keyword_pf",
    )

This succeeds:

keyword_search_qf = "{!type=edismax v=$keyword_query}"

def keyword_search(self, search_term):
    self.search(self.keyword_search_qf).raw_query_parameters(
        keyword_query=self._search_term_cleanup(search_term),
        qf="description_en_bigram",
        pf="description_en_bigram",
    )

In other words, it seems qf and pf have to be specified as raw query params, and it only accepts actual field names like description_en_bigram and not references to lists of boosted fields like $keyword_qf or $keyword_pf.

@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Merging #1406 (b2224c0) into develop (cc70b6d) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop    #1406      +/-   ##
===========================================
- Coverage    98.65%   98.65%   -0.01%     
===========================================
  Files          196      196              
  Lines        10751    10748       -3     
===========================================
- Hits         10606    10603       -3     
  Misses         145      145              

@blms
Copy link
Contributor Author

blms commented Jul 11, 2023

@rlskoeser Pushed an update that fixes search, but it does require defining the list of fields and boosts for each search in the raw query parameters. Is that OK? If so, there are cleaner ways to manage them than what I've done here, like lists concatenated into strings, so I can make that change—just doesn't seem to work to define them in the XML.

@rlskoeser
Copy link
Contributor

@blms I don't think defining the search fields in the query is a good solution.

Have you tried using the solr query analyzer to see what's going on?

@blms
Copy link
Contributor Author

blms commented Jul 20, 2023

@rlskoeser What are the drawbacks to that? Harder to maintain?

Yes, I have used the solr query analyzer and debugger to try and debug. Tried it again today and I'll document here:

With the original code, we get an attempt to literally look up the string {!type=edismax qf=$keyword_qf pf=$keyword_pf v=$keyword_query} (and thus 0 results):

    "rawquerystring":"{!type=edismax qf=$keyword_qf pf=$keyword_pf v=$keyword_query}",
    "querystring":"{!type=edismax qf=$keyword_qf pf=$keyword_pf v=$keyword_query}",
    "parsedquery":"+(DisjunctionMaxQuery((_text_:type)) DisjunctionMaxQuery((_text_:edismax)) DisjunctionMaxQuery((_text_:qf)) DisjunctionMaxQuery((_text_:keyword_qf)) DisjunctionMaxQuery((_text_:pf)) DisjunctionMaxQuery((_text_:keyword_pf)) DisjunctionMaxQuery((_text_:v)) DisjunctionMaxQuery((_text_:keyword_query)))",
    "parsedquery_toString":"+((_text_:type) (_text_:edismax) (_text_:qf) (_text_:keyword_qf) (_text_:pf) (_text_:keyword_pf) (_text_:v) (_text_:keyword_query))",

I thought there might be a problem with that syntax, so moving the string params into raw query params, like so:

search = self.raw_query_parameters(
    type="edismax",
    v=self._search_term_cleanup(search_term),
    qf="$keyword_qf",
    pf="$keyword_pf",
)

gets us this 400 error:

{
    "metadata": [
        "error-class",
        "org.apache.solr.common.SolrException",
        "root-error-class",
        "org.apache.solr.common.SolrException"
    ],
    "msg": "org.apache.solr.search.SyntaxError: Query Field '$keyword_qf' is not a valid field name",
    "code": 400
}

and without the $ before the query fields:

{
    "metadata": [
        "error-class",
        "org.apache.solr.common.SolrException",
        "root-error-class",
        "org.apache.solr.common.SolrException"
    ],
    "msg": "org.apache.solr.search.SyntaxError: Query Field 'keyword_qf' is not a valid field name",
    "code": 400
}

I couldn't figure out a way for it to pick up those fields from the XML config.

@blms blms marked this pull request as ready for review July 21, 2023 14:55
@blms
Copy link
Contributor Author

blms commented Jul 21, 2023

All working now thanks to your help @rlskoeser!

@blms blms requested a review from rlskoeser July 21, 2023 14:55
Copy link
Contributor

@rlskoeser rlskoeser left a comment

Choose a reason for hiding this comment

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

🎉🚀

@blms blms merged commit 97cd607 into develop Jul 21, 2023
8 checks passed
@blms blms deleted the chore/solr9-upgrade branch July 21, 2023 15:00
@blms blms restored the chore/solr9-upgrade branch August 9, 2023 19:13
@blms blms deleted the chore/solr9-upgrade branch August 9, 2023 19:32
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