0

Ive currently stumbled over a strange behavior from Solr while using PHP/Solarium.

I construct a query for a filterQuery and built it up like this:

$select = array(
        'query'     => $this->getSearchTermForQuery(),
        'fields'    => '*,score',
        'start'     => $this->numResultsPerPage * ($this->currentPage-1),
        'rows'      => $this->numResultsPerPage,
        'component' => array(
            'edismax' => array(
                'queryfields' => implode(' ', array(
                    $this->queryFields['firstArray'],
                    $this->queryFields['secondArray'],
                    $this->queryFields['thirdArray'],
                )),
            ),
        ),
        'sort' => $this->orderBy,
    );

the method "getSearchTermForQuery()" builds the string wich is sent to the Solr server. It worked perfectly with just single words or combinations like "Summer AND Winter". Now i wanted to implement a disjunction if it is explicitly wanted from the user input. So there would be a String like "Summer OR Winter". This one works perfectly as well. Now it gets complicated if i got something like "(Summer AND Winter) OR Winter". In this case i get a pretty strange result.

[edit] Hello again, My old examples make no sense anymore so i removed them. The current state i am at is better explained with the following.

I am now closer to the Problem i think. In the current state i am using the edismax queryparser. My Query looks like this:

#queryString: "((+"Test"+"Sommer")(+"Test"))"

With a low amount of queryfields everything seems to work and the parsed Query looks like this:

#parsedQuery: "(+((+DisjunctionMaxQuery((content:test | daad_imperia_title:test)) +DisjunctionMaxQuery((content:somm | daad_imperia_title:somm))) (+DisjunctionMaxQuery((content:test | daad_imperia_title:test)))))/no_coord"

This yields the expected result/behavior. But if i use all queryfields i want the structure of the parsed query changes. It the looks likes this:

#parsedQuery: "(+DisjunctionMaxQuery(((daad_stipdb_title:test daad_stipdb_title:summ daad_stipdb_title:test) | (daad_stipdb_furtherInformation:test daad_stipdb_furtherInformation:summ daad_stipdb_furtherInformation:test) | (daad_imperia_documentTitle:test daad_imperia_documentTitle:summ daad_imperia_documentTitle:test) | (daad_iO_hsportrait:test daad_iO_hsportrait:summer daad_iO_hsportrait:test) | (daad_imperia_forename:test daad_imperia_forename:summer daad_imperia_forename:test) | (daad_imperia_subtitle:test daad_imperia_subtitle:summer daad_imperia_subtitle:test) | (daad_stipdb_targetGroup:test daad_stipdb_targetGroup:summ daad_stipdb_targetGroup:test) | (daad_stipdb_moreInformation:test daad_stipdb_moreInformation:summ daad_stipdb_moreInformation:test) | (daad_stipdb_applicationLocation:test daad_stipdb_applicationLocation:summ daad_stipdb_applicationLocation:test) | (daad_iO_prepForSubject:test daad_iO_prepForSubject:summer daad_iO_prepForSubject:test) | (daad_imperia_multiselectLand:test daad_imperia_multiselectLand:summ daad_imperia_multiselectLand:test) | (daad_iO_cooperation:test daad_iO_cooperation:summer daad_iO_cooperation:test) | (daad_iO_addInformation:test daad_iO_addInformation:summer daad_iO_addInformation:test) | (daad_imperia_pmDocumentLabel01:test daad_imperia_pmDocumentLabel01:summ daad_imperia_pmDocumentLabel01:test) | (daad_stipdb_requirements:test daad_stipdb_requirements:summ daad_stipdb_requirements:test) | (daad_iO_digiCourseDescription:test daad_iO_digiCourseDescription:summer daad_iO_digiCourseDescription:test) | (daad_iO_institution:test daad_iO_institution:summer daad_iO_institution:test) | (daad_imperia_metaKeywords:test daad_imperia_metaKeywords:summ daad_imperia_metaKeywords:test) | (daad_imperia_multiselectTheme:test daad_imperia_multiselectTheme:summ daad_imperia_multiselectTheme:test) | (daad_stipdb_languageKnowledge:test daad_stipdb_languageKnowledge:summ daad_stipdb_languageKnowledge:test) | (daad_stipdb_subjects:test daad_stipdb_subjects:summ daad_stipdb_subjects:test) | (daad_stipdb_programName:test daad_stipdb_programName:summ daad_stipdb_programName:test) | (daad_imperia_metaDescription:test daad_imperia_metaDescription:summ daad_imperia_metaDescription:test) | (daad_imperia_intro:test daad_imperia_intro:summ daad_imperia_intro:test) | (url:test url:summer url:test) | (daad_iO_location:test daad_iO_location:summer daad_iO_location:test) | (daad_iO_digiCourseModules:test daad_iO_digiCourseModules:summer daad_iO_digiCourseModules:test) | (content:test content:summ content:test) | (daad_iO_subject:test daad_iO_subject:summer daad_iO_subject:test) | (daad_stipdb_teaser:test daad_stipdb_teaser:summ daad_stipdb_teaser:test) | (daad_imperia_pmLinkLabel01:test daad_imperia_pmLinkLabel01:summ daad_imperia_pmLinkLabel01:test) | (daad_iO_courseName:test daad_iO_courseName:summer daad_iO_courseName:test) | (daad_iO_keywords:test daad_iO_keywords:summer daad_iO_keywords:test) | (daad_imperia_linguas:test daad_imperia_linguas:summ daad_imperia_linguas:test) | (daad_stipdb_value:test daad_stipdb_value:summ daad_stipdb_value:test) | (daad_imperia_dateline:test daad_imperia_dateline:summ daad_imperia_dateline:test) | (daad_iO_organisation:test daad_iO_organisation:summer daad_iO_organisation:test) | (daad_imperia_profession:test daad_imperia_profession:summer daad_imperia_profession:test) | (daad_iO_fos:test daad_iO_fos:summer daad_iO_fos:test) | (daad_iO_internship:test daad_iO_internship:summer daad_iO_internship:test) | (daad_stipdb_efford:test daad_stipdb_efford:summ daad_stipdb_efford:test) | (daad_iO_degree:test daad_iO_degree:summer daad_iO_degree:test) | (daad_iO_studyAbroad:test daad_iO_studyAbroad:summer daad_iO_studyAbroad:test) | (daad_imperia_lastname:test daad_imperia_lastname:summer daad_imperia_lastname:test) | (daad_iO_cityPortrait:test daad_iO_cityPortrait:summer daad_iO_cityPortrait:test) | (daad_imperia_contact:test daad_imperia_contact:summ daad_imperia_contact:test) | (daad_stipdb_subjectGroups:test daad_stipdb_subjectGroups:summ daad_stipdb_subjectGroups:test) | (daad_imperia_subhead:test daad_imperia_subhead:summ daad_imperia_subhead:test) | (daad_imperia_professionShort:test daad_imperia_professionShort:summer daad_imperia_professionShort:test) | (daad_stipdb_targets:test daad_stipdb_targets:summ daad_stipdb_targets:test) | (daad_stipdb_status:test daad_stipdb_status:summ daad_stipdb_status:test) | (daad_stipdb_progType:test daad_stipdb_progType:summ daad_stipdb_progType:test) | (daad_stipdb_longNames:test daad_stipdb_longNames:summ daad_stipdb_longNames:test) | (daad_iO_typeOfIntitution:test daad_iO_typeOfIntitution:summer daad_iO_typeOfIntitution:test) | (daad_imperia_title:test daad_imperia_title:summ daad_imperia_title:test) | (daad_stipdb_length:test daad_stipdb_length:summ daad_stipdb_length:test) | (daad_stipdb_targetCountries:test daad_stipdb_targetCountries:summ daad_stipdb_targetCountries:test) | (daad_iO_leisureProgramme:test daad_iO_leisureProgramme:summer daad_iO_leisureProgramme:test) | (daad_stipdb_originCountries:test daad_stipdb_originCountries:summ daad_stipdb_originCountries:test) | (daad_iO_courseContent:test daad_iO_courseContent:summer daad_iO_courseContent:test) | (daad_stipdb_contacts:test daad_stipdb_contacts:summ daad_stipdb_contacts:test))))/no_coord"

It just creates one big dismaxQuery with all words from the query. Someone any idea? I think im going mad with this...

I hope someone can give me a hint on this.

Best regards, Ronald

LongRon
  • 73
  • 1
  • 9

1 Answers1

1

Disclaimer: I'm the author of Solr Query Debugger Google Chrome plugin.

Mostly depends on how is configured your collection and what kind of query parser are you using (I assume edismax).

If you can tail the log file of your Solr instance this would help you to get the real query submitted.

In this way you could use that query in your browser and then debug it.

Indeed I suggest to use a debugger in order to see what's is execute and explain why your query have such strange behaviour.

There are others debuggers:

So just execute the Solr query in your browser and if it works then start the Solr Debugger you prefer.

In my plugin page you'll see Debug and Echo tabs where explain what's executed by Solr. In the Explain tab you'll see the score explanations structured as a tree.

Hope this helps.

freedev
  • 25,946
  • 8
  • 108
  • 125
  • Thank you for your answer. I must admit that i am not that deep into this subject as i would like to be. I added the log for my request into my question. It doesnt make me any smarter to be honest. I hope you or someone else can read something out of that. While hoping for more answers i try my best at one of the debuggers you suggested. Thanks a lot – LongRon Mar 28 '17 at 06:23
  • Hello again. With your chrome Plugin i found this to be the parsedquery_toString: +((content:test | title:test^10.0 | url:test^7.0) (url:or^7.0) (content:summ | title:summ^10.0 | url:summer^7.0) (url:and^7.0) (content:test | title:test^10.0 | url:test^7.0)) Maybe a hint here? – LongRon Mar 28 '17 at 06:32
  • @LongRon Debuggers helps you to understand relevancy problems but you should already know a little how Solr works (query parser, filter chains, tokenizations, etc.). Looking at your second comment I see that `and` and `or` as keyword are in your search but they are search operators. What kind of query parser are you using, looking at your post edit I see `defType=dismax` but may be in your comment you're using a different one. – freedev Mar 28 '17 at 10:05
  • @LongRon to be clear you should not use curly brackets in your search `{"Test" OR ("Summer" AND "Test")}` should be written: `Test OR ("Summer" AND "Test")` – freedev Mar 28 '17 at 10:18
  • i changed the defType to edismax today and it seems that the query parser ignores my and/or operators. The default operator, which i switched a few times inside my solrconfig.xml, and puts them between every phrase including the OR/AND's The curly brackets were a test because i saw it in one of the threads i found. Didnt help didnt make it worse also. Changed it again but thanks for that hint and all the others ;) – LongRon Mar 28 '17 at 10:48
  • Use edismax is a good start. When your query returns few rows, use the plugin and have a look at the `Explain` tab, there you'll find information about what field has matched and why. This could help you to understand how the thing works. When you change the `solrconfig.xml` remember to reload the collection or restart Solr, this is a common mistake. – freedev Mar 28 '17 at 11:14
  • Hello freedev, i am closer to the problem now i guess. I updated my initial post. Can you take a look at the current state? Thanks in advance – LongRon Apr 12 '17 at 08:07