简体   繁体   English

Symfony elasticsearch包

[英]Symfony elasticsearch bundle

I try to execute example from: 我尝试从执行示例:

https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/2.1.x/README.md 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);

Configuration: 组态:

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:

I have same configuration and db tables, but I get error: 我有相同的配置和数据库表,但出现错误:

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]]; }]

What can couse this problem ? 有什么可以解决这个问题? maybe elasticsearch server version ? 也许elasticsearch服务器版本?

Have you tried to flush your cache and (re)populate your index? 您是否尝试刷新缓存并(重新)填充索引?

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

Then just reload your query. 然后,只需重新加载查询即可。

There's also a typo in the yml (before analysis). yml中还有一个错字(在分析之前)。

First of all check elasticsearch is running or not: 首先检查elasticsearch是否在运行:

$ Curl localhost:9200

It will return the version of elasticsearch. 它将返回elasticsearch的版本。 After that check if your indexes appeared in elasticsearch or not: 之后,检查您的索引是否出现在elasticsearch中:

$ curl http://localhost:9200/_aliases?pretty=1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM