I want to use the elastic4s api to delete and create templates.
I couldn't find an api to create a template with a given content, only create by providing a name.
Not sure how to use the IndexTemplateDsl.
Is this the right direction?
You create the template with a name, and then specifying the pattern match for that template, then you can add your mappings.
val req = create template "my_template" pattern "matchme.*" mappings(
mapping("sometype1").fields(
stringField("field1"),
geopointField("field2")
),
mapping("sometype2").fields(
stringField("field3"),
intField("field4")
)
)
client.execute(req)
So it's very similar to creating a normal index.
Related
Here is the the problem. Let's say, I have this rule:
{
pattern: ( [ner:/DATE|TIME/] ),
action: ( Annotate($0, myNER, "MY_DATETIME" ) )
}
Instead of annotating the capture group $0, how can I specify the entire document, sort of like this:
{
pattern: ( [ner:/DATE|TIME/] ),
action: ( Annotate( <document>, myNER, "MY_DATETIME" ) )
}
This can be a very useful feature that allows annotating the whole document (or perhaps a sentence) when a specific token pattern is found. Thanks.
At the moment there isn't an implemented way to do this. There isn't a direct way to get access to the CoreMap representing the document through TokensRegex.
What would be necessary is for every token to have a pointer to the document CoreMap, then you could access the overall document in the TokensRegex rules by looking at a specific token, but this would require making some changes to the code.
If you want to open a GitHub issue we could try to add this functionality in future versions.
I am trying to dynamically add a field using groovy script where if the field exists then just add a new element to the array,if not then create the field with the first value.
if(!ctx._source.containsKey(\"Activities\")) { ctx._source.Activities = [activity] }else{ctx._source.Activities += activity}
I am passing the activity param properly but this operation is returning a error:
"remote_transport_exception:
[Stonecutter][127.0.0.1:9300][indices:data/write/update[s]]"
Do you guys have any suggestion?
The map object of your Doc does not support the "+=" operator, u can checkout the right way to update the Doc in the official guide.
I want to load a folder of HTML templates in Go and right now I can only pass in each file path as a string in an argument.
Example:
templates = template.Must(template.ParseFiles("../web/html_templates/edit.html","../web/html_mplates/view.html"))
Works fine.
This and similar solutions won't work:
templates = template.Must(template.ParseFiles("../web/html_templates/*"))
I'd like to specify my templates in a config file but I currently can't. What's the best way to go about this?
Use ParseGlob to parse a folder of HTML templates in one API call.
templates = template.Must(template.ParseGlob("../web/html_templates/*.html"))
See the Match function documentation for the glob syntax.
You could use the fact that template.ParseFiles is a variadic function :
var templatesFiles []string
// [...]
// Here fill the slice from your config file or any other source
// [...]
templates = template.Must(template.ParseFiles(templatesFiles...))
I'm working on creating a custom report report page in CQ5. I've got my reportbase and columnbase components set up correctly, by following the steps listed here. I am able to, for instance, pick up all the templates that are available, by setting the property nodeTypes to cq:Template
I want to add a constraint to it, say for example pick up templates whose jcr:title is foo. I created a node under querybuilder called propertyConstraints and added my constraints in the form of nodes below it, as describedhere. However, this does not work for me at all.
What is the correct way to add constraints to the querybuildernode? Has anyone tried this?
Also, once I get this working correctly, can I extend this example to return pages of a specific template?
Have you looked into the QueryBuilder API? Adobe's documentation discusses how to match 1 or more property values.
Create a node propertyConstraints under queryBuilder of type nt:unstructured
create another node under propertyConstraints with any name.
Add properties to this node :
name String jcr:title
value String foo
I'm generating XML file dynamiquely from database using Ruby Builder (http://builder.rubyforge.org/).
To add a Tag which name is in a variable, I found this:
xml.tag!(#myTagName)
How to dynamiquelly insert à list of attributes in this Tag ?
I dont know the names of the attributes which are loaded dynamically from database
I need to create a loop because I dont know how many attributes will be inserted.
Thanks.
I think it shouldn't be hard to do what you need. Whenever you add a tag you can pass along an optional hash which will be the tag's attributes. So for example if you do:
builder = Builder::XmlMarkup.new
xml = builder.person(name: "foo", age: 0 )
Then you will get <person name='foo' age='0'/>
So in a similar way if you build your dynamic attributes as a hash you can use the #tag! method like the following:
xml = builder.tag!(tag_name, attributes_hash)