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

Backslashes in the query string not supported? #55

Open
Dom-nik opened this issue Dec 22, 2016 · 1 comment
Open

Backslashes in the query string not supported? #55

Dom-nik opened this issue Dec 22, 2016 · 1 comment

Comments

@Dom-nik
Copy link

Dom-nik commented Dec 22, 2016

  • Version: ES/Logstash 5.0.2, plugin: 3.1.0
  • Operating System: CentOS 7
  • Config File (the query I used is in the comment):
input {
        elasticsearch {
                hosts => "10.x.y.z:9200"
                index => "data_for_mapping_test"
                query => '
{
  "query": {
    "term": {
      "_id": {
        "value": "1"
      }
    }
  }
}
'
        }
}

filter {
     elasticsearch {
              hosts => ["10.x.y.z:9200"]
              index => "mappings"
              query_template => "/etc/logstash/conf.d/mapping_test.dsl"
              # query => '{ "query": { "term": { "AssetType": "%{AssetType}"} } }'
              fields => {"AssetTypeGrouping" => "AssetTypeGroupingMapped"}
              enable_sort => false
     }
}

output {
    elasticsearch {
        hosts => ["10.x.y.z:9200"]
        index => "mappings_test"
    }
}
  • Sample Data:
    My input data contains a field like this: "AssetType":"\\Demo\\Something"
    My mappings index contains documents like this:
{
        "AssetType": "\\Demo\\Something",
        "AssetTypeGrouping": "marketing assets"
}
  • Steps to Reproduce: Run the pipe ;]
  • Error:

:error=>#<LogStash::Json::ParserError: Unrecognized character escape 'D' [...]

NOTE: It helped (worked as expected) when I added the following step in the query parsing in the plugin code:

query_tmp = event.sprintf(@query_dsl).gsub!('\\', '\\\\\\')

So it seems that the query parser doesn't understand backslashes in the query string.
Is it the solution or am I doing something completely stupid?

@webmat
Copy link
Contributor

webmat commented Apr 30, 2018

Sorry about the delay here :-(

Did the fix in ElasticSearch help with the issue on the Logstash side?

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