New Control visualization with scripted field

I’m currently pulling data from Pipedrive and would like to make a new control filter that would be based on string values in my data.

My index contains Deal_title that is in the form - CompanyName Ltd (xxxx) The information inside the brackets changes.

Correct me if I’m wrong, but in order to have the control visualization I’ll need to do the following:

  • Create new scripted field that will add a new field in my index
  • Use that Scripted field for control visualization

The problem is that I have no idea how to write this script that would take my string data and create new index value whenever it finds brackets.

Sorry, I'm not clear on the question. Can you share some example documents and what you'd expect the control options to be?

Deal title indexing is as follows:

"Deal_title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256

Resulting in:

I'd like to make a new control visualization that would have only the lead source that is in the brackets (maby 5-6 different sources).

I think I'll have to make a new field from deal title data with script field and write code with painless that takes end of string and creates a new field in my index from whatever is inside of those brackets.

I'm new to painless, so I have no idea how to do this.

Thanks for clarifying. Yes, I think you'll want to use a Painless regular expression in a scripted field for this.

Here's a scripted field example that will extract "Bar" from "Foo (Bar)".

def m = /\((.*)\)/.matcher(doc['name'].value);
if ( m.find() ) {
} else {
   return ''
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.