Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not work when create index with mapping #3

Closed
nnhatnam opened this issue Oct 28, 2014 · 3 comments
Closed

Not work when create index with mapping #3

nnhatnam opened this issue Oct 28, 2014 · 3 comments

Comments

@nnhatnam
Copy link

When I create a new index , specifying that the "content" field use the vi_analyzer analyzer:

PUT http://localhost:9200/test/
{
"mappings": {
"data": {
"properties": {
"content": {
"type": "string",
"analyzer": "vi_analyzer"
}
}
}
}
}
}

Then I index the follow document :

POST http://localhost:9200/test/data/
{
"content": "Công nghệ thông tin Việt Nam",
"id": 100
}

However, when I search

POST http://localhost:9200/test/data/_search/
{
"query": {
"match": {
"content": "Công nghệ thông tin"
}
}

I received that result:
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 4,
"failed": 1,
"failures": [
{
"index": "test",
"shard": 0,
"status": 400,
"reason": "SearchParseException[[test][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"match":{"content":"Công nghệ thông tin"}}}]]]; nested: NullPointerException; "
}
]
},
"hits": {
"total": 0,
"max_score": null,
"hits": [ ]
}
}

In elasticsearch console, I received an exception:

org.elasticsearch.search.SearchParseException: [test][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"match":{"content":"Công nghệ thông tin"}}}]]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:660)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:516)
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:488)
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:257)
at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)
at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)
at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at java.util.regex.Matcher.getTextLength(Matcher.java:1234)
at java.util.regex.Matcher.reset(Matcher.java:308)
at java.util.regex.Matcher.(Matcher.java:228)
at java.util.regex.Pattern.matcher(Pattern.java:1088)
at vn.hus.nlp.tokenizer.Tokenizer.getNextToken(Tokenizer.java:438)
at vn.hus.nlp.tokenizer.Tokenizer.tokenize(Tokenizer.java:214)
at org.apache.lucene.analysis.vi.VietnameseTokenizer.tokenize(VietnameseTokenizer.java:83)
at org.apache.lucene.analysis.vi.VietnameseTokenizer.reset(VietnameseTokenizer.java:141)
at org.apache.lucene.analysis.TokenFilter.reset(TokenFilter.java:70)
at org.apache.lucene.analysis.TokenFilter.reset(TokenFilter.java:70)
at org.apache.lucene.analysis.util.FilteringTokenFilter.reset(FilteringTokenFilter.java:111)
at org.apache.lucene.util.QueryBuilder.createFieldQuery(QueryBuilder.java:208)
at org.apache.lucene.util.QueryBuilder.createBooleanQuery(QueryBuilder.java:87)
at org.elasticsearch.index.search.MatchQuery.parse(MatchQuery.java:210)
at org.elasticsearch.index.query.MatchQueryParser.parse(MatchQueryParser.java:165)
at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:239)
at org.elasticsearch.index.query.IndexQueryParserService.innerParse(IndexQueryParserService.java:342)
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:268)
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:263)
at org.elasticsearch.search.query.QueryParseElement.parse(QueryParseElement.java:33)
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:644)
... 9 more

Am I missing something ? My elasticsearch version is 1.3.4 (I've tried GET /_analyze?analyzer=standard&text="Công nghệ thông tin Việt Nam", it worked correctly but not work when use on mapping). Sorry for my bad English.

@duydo
Copy link
Owner

duydo commented Oct 29, 2014

I've just tested, it works as expected. You can execute following commands to verify:
Check the plugin if it works

curl -XGET "http://localhost:9200/_analyze?analyzer=vi_analyzer&text="Công nghệ thông tin Việt Nam"

Create index test

curl -XPUT "http://localhost:9200/test/" -d'
{
  "mappings": {
    "data": {
      "properties": {
        "content": {
          "type": "string",
          "analyzer": "vi_analyzer"
        }
      }
    }
  }
}'

Index a document

curl -XPOST "http://localhost:9200/test/data" -d'
{
"content": "Công nghệ thông tin Việt Nam",
"id": 100
}'

Search

curl -XGET "http://localhost:9200/test/data/_search" -d'
{
  "query": {
    "match": {
      "content": "Công nghệ thông tin"
    }
  }
}'

Result

{
   "took": 2,
   "timed_out": false,
   "_shards": {
      "total": 1,
      "successful": 1,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 0.19178301,
      "hits": [
         {
            "_index": "test",
            "_type": "data",
            "_id": "RESXVjERQsikqHfzjvOg5w",
            "_score": 0.19178301,
            "_source": {
               "content": "Công nghệ thông tin Việt Nam",
               "id": 100
            }
         }
      ]
   }
}

@nnhatnam
Copy link
Author

I've tried but it still had the same problem. I tried to reinstall elasticsearch but nothing change. I think I missing something. I'll try on another computer :(

@duydo
Copy link
Owner

duydo commented Nov 2, 2014

Have you resolved the issue? If yes, I close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants