我目前在使用PHP /日光浴时偶然发现Solr的一个奇怪行为。
我为filterQuery构建了一个查询,并按如下方式构建:
$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,
);
方法" getSearchTermForQuery()"构建发送到Solr服务器的字符串。 它完美地适用于单个单词或组合,例如"夏天和冬天"。现在我想实现一个析取,如果从用户输入明确需要它。所以会有一个类似"夏天或冬天"的字符串。 这个也很完美。现在,如果我得到类似"(夏季和冬季)或冬季"这样的事情就变得复杂了。在这种情况下,我得到一个非常奇怪的结果。
[编辑] 再次问好, 我的旧例子不再有意义所以我删除了它们。我现在处于的状态可以通过以下方式得到更好的解释。
我现在更接近我认为的问题了。在目前的状态下,我正在使用edismax queryparser。 我的查询如下所示:
#queryString: "((+"Test"+"Sommer")(+"Test"))"
查询字段数量较少似乎一切正常,解析后的查询如下所示:
#parsedQuery: "(+((+DisjunctionMaxQuery((content:test | daad_imperia_title:test)) +DisjunctionMaxQuery((content:somm | daad_imperia_title:somm))) (+DisjunctionMaxQuery((content:test | daad_imperia_title:test)))))/no_coord"
这会产生预期的结果/行为。 但是,如果我使用所有查询字段,我希望解析查询的结构发生变化。看起来像这样:
#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"
它只是用查询中的所有单词创建一个大的dismaxQuery。 有人有什么想法吗?我想我很生气...
我希望有人可以给我一个暗示。
祝你好运, 罗纳德
答案 0 :(得分:1)
免责声明:我是Solr Query Debugger Google Chrome插件的作者。
主要取决于您的集合的配置方式以及您使用的查询解析器类型(我假设为edismax
)。
如果您可以拖尾Solr实例的日志文件,这将有助于您提交真实的查询。
通过这种方式,您可以在浏览器中使用该查询,然后进行调试。
确实,我建议使用调试器来查看执行的内容并解释为什么查询会出现这种奇怪的行为。
还有其他调试器:
所以只需在浏览器中执行Solr查询,如果有效,则启动您喜欢的Solr Debugger。
在我的插件页面中,您会看到Debug
和Echo
标签,其中说明了Solr执行的操作。在Explain
标签中,您会看到以树形结构的分数解释。
希望这有帮助。