簡體   English   中英

Symfony elasticsearch包

[英]Symfony elasticsearch bundle

我嘗試從執行示例:

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中還有一個錯字(在分析之前)。

首先檢查elasticsearch是否在運行:

$ Curl localhost:9200

它將返回elasticsearch的版本。 之后,檢查您的索引是否出現在elasticsearch中:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM