I'm using the elastic rest component https://camel.apache.org/components/latest/elasticsearch-rest-component.html
I'm not able to specify the id of a document in any way. The documentation seems to have a lack in this sense
the code is more o less like
from(RAW_ROUTE)
.process(new RawProcessor())
.to("elasticsearch://local?operation=Index&indexName=raw&indexType=_doc")
;
The RawProcessor set a Map as body of the exchange object
Many thanks in advance
_id can be set with indexId header.
See Message Operations:
Index: Adds content to an index and returns the content’s indexId in the body. You can set the indexId by setting the message header with the key "indexId"
You can find example usage in unit test ElasticsearchIndexTest#testIndexWithIDInHeader.
Related
Hello I am trying to insert an object into elasticsearch using it's API, the problem is that the IDs of elements that I want to insert are like this : ee5z4d5/54zd15zd/5zd45
when I sent a post request to host/index/id with a body, I got an error because the request url is host/index/ee5z4d5/54zd15zd/5zd45
I am using spring boot with feign client to comminucate with elasticsearch, and my question is how I can solve this problem
You need to URL-encode your ID first, i.e. the URL must look like this
host/index/ee5z4d5%2F54zd15zd%2F5zd45
I don't know Feign but this issue might provide some insights on how to solve your issue.
Tldr;
This is not an Elastic issue but more a web issue.
What you need to do, is encode the special char in the url.
Look at the solution below to find out what it means.
Solution
POST /73690410/_doc/ee5z4d5%2F54zd15zd%2F5zd45
{
"data": "my id has some slash"
}
I am working on a Jmeter LDAP test plan and the test plan has to populate an attribute on the LDAP that is multi-valued.
When I do an LDAP search sampler, I noted that the value I get back is a string, with the values separated by ", ".
But, if I take the same comma-separated string and try to do an LDAP modify or add, using either an LDAP Request or LDAP Extended Request, I get an error.
So I am wondering if there is a way that the Jmeter LDAP Request or LDAP Extended Request can do that?
Thanks,
Jim
EDIT: When I try to use an Extended LDAP Request modification test/add with the attribute of "", I get this error in the Jmeter GUI response:
When attempting to modify entry cn=xxx... to replace the set of values for attribute lastlogindate, value "20181023085627-04, 20181024063205-04" was found to be invalid according to the associated syntax: The provided value "20181023085627-04, 20181024063205-04" is not a valid generalized time value because it contains an invalid character '-' at position 14
The strange part is that even though I have Jmeter to log at debug level, I don't see any detail on the error in the Jmeter.log, but/so I am guessing that that error message is coming from the Jmeter client itself. I noticed that the message says:
to replace the set of values
so it seems like it recognizes that I am trying to modify/replace a multi-value, but it doesn't seem to like the syntax of the replacement values string(s).
Does anyone know what the correct format SHOULD be?
I found the answer to my own question, or at least "A" answer: It appears that I can use an Extended LDAP request, and add the same attribute in that request, multiple times. So for example, if I am populating an attribute named "foo" the Extended LDAP request would have the following:
attribute value opcode
foo 12345 add
foo 12346 add
etc.
I think I also need to do a replace with no value, to empty the attribute, before all the adds.
I am using Spring JPA with mongo.I have a requirement to use contains query on one of the fields.If end users(UI/Service) hits the GET Request and looks for information in EMAIL Field,I need to search based on text.Pretty much it is like.
https://docs.spring.io/spring-data/jpa/docs/current/reference/html/
This link explains that We can Use Contains to get the Data.
List<ScheduledNotification> findByMobileNumberContaining(String mobileNumber);
List<ScheduledNotification> findByEmailIdIgnoreCaseContaining(String emailId);
But when I am using this API,I am not able to get the data.So ,has any one done something like using Contains.
well ,I was not sending content type in header attribute in GET request.So yes it works,alright.There was no issue with method signature.
I need to know how to update the values in nifi processors using Rest API.
https://nifi.apache.org/docs/nifi-docs/rest-api/index.html
For example: I have used below processor structure
GetFile>SplitText>ExtractText>ReplaceText>ConvertJSONToSQL>PUTSQL.
I have passed following inputs for above processors.,
FileLocation(GetFile).
validation(ExtractText).
ReplacementValue(ReplaceText).
DBCP ConnectionPool,username and pwd for SQL.
I just need to use nifi rest api client to write above inputs into processors.
For example : If I give Processor name and input file in Rest API Client then it will write into processor.
Please stop me if anything i'm doing wrong.
Help Appreciated and Tell me any other ways is possible?
Mahen,
You can issue a PUT request to /processors/{id} and provide the new value of the "Replacement Value" property. You'll need to provide JSON body in the request to do this, and you can see the structure by expanding the endpoint noted above on the documentation link you provided, then clicking ProcessorEntity > ProcessorDTO > ProcessorConfigDTO to see the pop-up dialogs with the element listing and examples. You can also quickly get the current values of the processor by issuing a GET request to /processors/{id}.
I would like to run an elasticsearch query to find items within 10mi of a given point.
I know how to do it with a post, but I would like to use a get with everything in the uri.
I found the below example but it does not work.
http://localhost:9200/items/item/_search?{%22query%22:{%22filtered%22:{%22query%22:{%22match_all%22:{}},%22filter%22:{%22geo_distance%22:{%22distance%22:%220.1km%22,%22location%22:{%22lat%22:46.884106,%22lon%22:-71.377042}}}}}}
Any way to do this or am I stuck using a post?
The key is the source= parameter. Not to be confused with _source.
http://localhost:9200/items/item/_search?source={%22query%22:{%22filtered%22:{%22query%22:{%22match_all%22:{}},%22filter%22:{%22geo_distance%22:{%22distance%22:%220.1km%22,%22location%22:{%22lat%22:46.884106,%22lon%22:-71.377042}}}}}}
I had tried ?q= and a few other parameters listed on http://www.elasticsearch.org/guide/reference/api/search/uri-request/ with no luck (source is not listed).
I found http://www.elasticsearch.org/guide/reference/api/ and at the very bottom it says
request body in query string
For libraries that don’t accept a request body for non-POST requests,
you can pass the request body as the source query string parameter
instead.
So structure your query/filter request, set it all on one line and send it into the source parameter.
Do not use the q= parameter with source= or it will conflict and break the query, however I tried size= and from= and they work with source just fine.