php - Symfony elasticsearch包

标签 php symfony elasticsearch

我尝试从执行示例:

https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/2.1.x/README.md

$fieldQuery = new \Elastica_Query_Text();
$fieldQuery->setFieldQuery('title', 'I am a title string');
$fieldQuery->setFieldParam('title', 'analyzer', 'my_analyzer');
$boolQuery->addShould($fieldQuery);

组态:
fos_elastica:
    clients:
        default: { host: localhost, port: 9200 }
    indexes:
        site:
            settings:
                index:
                  analysis:
                        analyzer:
                            my_analyzer:
                                type: snowball
                                language: English
            types:
                article:
                    mappings:
                        title: { boost: 10, analyzer: my_analyzer }
                        tags:
                        categoryIds:
                    persistence:
                        driver: orm
                        model: Acme\DemoBundle\Entity\Article
                        provider:
                        finder:

我有相同的配置和数据库表,但出现错误:
SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; 
  shardFailures {[qtEeqhjbTyWPoPlp9mhwGQ][site][0]: SearchParseException[[site][0]: from[-1],size[-1]: 
    Parse Failure [Failed to parse source [
      {
        "query": {
          "bool": {
            "should": [
              {
                "text": {
                  "artText": {
                    "query": "I am a title string"
                  }
                }
              }
            ]
          }
        }
      }
    ]]]; 
  nested: QueryParsingException[[site] No query registered for [text]]; }{[qtEeqhjbTyWPoPlp9mhwGQ][site][1]: 
  SearchParseException[[site][1]: from[-1],size[-1]: 
    Parse Failure [Failed to parse source [
      {
        "query": {
          "bool": {
            "should": [
              {
                "text": {
                  "artText": {
                    "query": "I am a title string"
                  }
                }
              }
            ]
          }
        }
      }
    ]]]; 
  nested: QueryParsingException[[site] No query registered for [text]]; }{[qtEeqhjbTyWPoPlp9mhwGQ][site][2]: 
  SearchParseException[[site][2]: from[-1],size[-1]: 
    Parse Failure [Failed to parse source [
      {
        "query": {
          "bool": {
            "should": [
              {
                "text": {
                  "artText": {
                    "query": "I am a title string"
                  }
                }
              }
            ]
          }
        }
      }
    ]]]; 
  nested: QueryParsingException[[site] No query registered for [text]]; }{[qtEeqhjbTyWPoPlp9mhwGQ][site][3]: 
  SearchParseException[[site][3]: from[-1],size[-1]: 
    Parse Failure [Failed to parse source [
      {
        "query": {
          "bool": {
            "should": [
              {
                "text": {
                  "artText": {
                    "query": "I am a title string"
                  }
                }
              }
            ]
          }
        }
      }
    ]]]; 
  nested: QueryParsingException[[site] No query registered for [text]]; }{[qtEeqhjbTyWPoPlp9mhwGQ][site][4]: 
  SearchParseException[[site][4]: from[-1],size[-1]: 
    Parse Failure [Failed to parse source [
      {
        "query": {
          "bool": {
            "should": [
              {
                "text": {
                  "artText": {
                    "query": "I am a title string"
                  }
                }
              }
            ]
          }
        }
      }
    ]]]; 
  nested: QueryParsingException[[site] No query registered for [text]]; }]

有什么可以解决这个问题?也许elasticsearch服务器版本?

最佳答案

您是否尝试刷新缓存并(重新)填充索引?

php app/console cache:clear
php app/console f:e:p

然后,只需重新加载查询即可。

yml中也有错字(在分析之前)。

关于php - Symfony elasticsearch包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27769666/

相关文章:

PHP 搜索查询与插入语句

php - 使用端口转发和 php 与 mysql_connect 连接到远程服务器

symfony - 如何从 symfony2 项目中删除供应商?

mysql - 包含不正确信息的 Symfony2 和 GoDaddy 错误消息

MongoDB + Elasticsearch 还是只有 Elasticsearch?

elasticsearch - elasticsearch获取分析领域的统计数据

php - 当其中已经有内容时,如何获取 xml 标签的内部文本?

javascript - AJAX 表单不显示成功或错误消息

deployment - Capifony 和目录所有者

elasticsearch - Elasticsearch:通过映射对索引字段进行GET请求