FilderQuery 与 Solarium 的析取

问题描述 投票:0回答:1

我目前在使用 PHP/Solarium 时偶然发现了 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 服务器的字符串。

它与单个单词或“夏季和冬季”等组合完美配合。现在,如果用户输入明确需要它,我想实现一个析取。所以会有一个像“Summer OR Winter”这样的字符串。

这个也很完美。现在,如果我得到类似“(夏季和冬季)或冬季”之类的内容,事情就会变得复杂。在这种情况下,我得到了一个非常奇怪的结果。

[编辑]
又好,
我的旧示例不再有意义,因此我删除了它们。我目前所处的状态可以通过以下更好地解释。

我现在更接近我认为的问题了。在当前状态下,我正在使用 edismax 查询解析器。

我的查询如下所示:

#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。 有人有什么想法吗?我想我要疯了......

我希望有人能给我一点提示。

php solr solarium
1个回答
1
投票

免责声明:我是 Solr Query Debugger Google Chrome 插件的作者。

主要取决于如何配置您的集合以及您使用哪种查询解析器(我假设

edismax
)。

如果您可以跟踪 Solr 实例的日志文件,这将帮助您获取提交的真实查询。

通过这种方式,您可以在浏览器中使用该查询,然后对其进行调试。

事实上,我建议使用调试器来查看正在执行的内容并解释为什么您的查询有如此奇怪的行为。

还有其他调试器:

因此,只需在浏览器中执行 Solr 查询,如果有效,则启动您喜欢的 Solr 调试器。

在我的插件页面中,您将看到

Debug
Echo
选项卡,其中解释了 Solr 执行的内容。在
Explain
选项卡中,您将看到树状结构的分数说明。

希望这有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.