2015-01-04 62 views
2

我尝试从执行例如: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服务器版本?

回答

0

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

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

然后只是重新加载您的查询。

yml中还有一个错字(分析前)。

0

所有检查elasticsearch首先运行与否:

$ Curl localhost:9200 

它将返回elasticsearch的版本。之后检查您的索引是否出现在elasticsearch搜索中:

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