2014-03-30 5 views
0

단어의 일부 또는 단어의 시작 부분을 검색 할 수있는 신축성있는 검색을 설정하는 방법.elasticsearch로 단어의 시작 부분을 검색하는 방법은 무엇입니까?

다음 스크립트를 실행하면 'inte *'가 아닌 이상 접두어 'inte'를 찾지 못합니다.

여기에 무슨 문제가 있는지 알 수 없습니다. 당신이 here을 볼 수

echo "--- DELETING OLD INDEX ---" 

curl -XDELETE 'http://localhost:9200/searchtest?pretty' 

echo "--- CREATING INDEX ---" 

curl -XPUT 'http://127.0.0.1:9200/searchtest/?pretty=1' -d '{ 
    "mappings" : { 
     "mytype" : { 
     "properties" : { 
      "description": { 
       "type": "string", 
       "index_analyzer": "my_analyzer", 
       "search_analyzer": "standard" 
      } 
     } 
     } 
    }, 
    "settings" : { 
     "analysis" : { 
     "analyzer" : { 
      "my_analyzer" : { 
       "filter" : [ "standard", "lowercase", "stop" ], 
       "type" : "custom", 
       "tokenizer" : "my_tokenizer" 
      } 
     }, 
     "tokenizer" : { 
      "my_tokenizer" : { 
       "side" : "front", 
       "max_gram" : 200, 
       "type" : "edgeNGram" 
      } 
     } 
     } 
    } 
}' 

echo "--- INSERTING RECORDS ---" 

curl -XPOST 'http://localhost:9200/searchtest/mytype?pretty=1' -d '{ 
    "description": "Programming International!" 
}' 

curl -XPOST 'http://localhost:9200/searchtest/mytype?pretty=1' -d '{ 
    "description": "i18n is internationalizatin" 
}' 

echo "--- REFRESH ---" 

curl -XPOST 'http://localhost:9200/_refresh?pretty=1' 

echo "--- RUNNING QUERY WITH * ---" 

curl -XGET 'http://localhost:9200/searchtest/mytype/_search?pretty' -d ' 
{ 
    "query" : { 
     "query_string" : { 
     "query" : "inte*" 
     } 
    } 
}' 

echo "--- RUNNING QUERY ---" 

curl -XGET 'http://localhost:9200/searchtest/mytype/_search?pretty' -d ' 
{ 
    "query" : { 
     "query_string" : { 
     "query" : "inte" 
     } 
    } 
}' 

그 아무 문제가 없습니다

답변

2

[내가 elasticsearch 0.90.9을 사용하고, 질의 문은 와일드 카드를 지원하는 쿼리 파서를 사용합니다.

어쩌면 당신이 특정 접두어로 시작하는 용어와 일치 접두사 쿼리를 찾고 있습니다 ... 난 당신이 와일드 카드 쿼리를 찾고 생각이 link

curl -XGET 'http://localhost:9200/searchtest/mytype/_search?pretty' -d ' 
{ 
    "query" : { 
    "prefix" : { 
     "description" : { 
      "value" : "inte" 
     } 
    } 
    } 
}' 
+0

아래와 같이 와일드 카드 쿼리보다 확장 성이 좋습니다. – Nate

0

에 대해 살펴

curl -XPOST "http://_search" -d' 
{ 
"query": { 
    "wildcard": { 
     "description": { 
      "value": "inte*" 
         } 
       } 
     } 
}' 

와일드 카드 및 정규식 쿼리에 대해 위 쿼리를 시도하십시오!

호프 도움이 ..!

관련 문제