Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions components/camel-solr/src/main/docs/solr-component.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ the following. Some operations also require the message body to be set.
|=======================================================================
|Operation |Message body |Description

|`INSERT` | n/a |inserts/updates a document using message headers (solr fields must be prefixed with "SolrField.")
|`INSERT` | n/a |inserts/updates a document using message headers (solr fields must be prefixed with "CamelSolrField.")
|`INSERT` | File |inserts/updates a document or documents using the given File (using ContentStreamUpdateRequest)
|`INSERT` | SolrInputDocument or Collection<SolrInputDocument>|inserts/updates a document or documents based on the given (collection of) SolrInputDocument
|`INSERT` | bean or Collection<bean> |inserts/updates a document or documents based on values in an http://wiki.apache.org/solr/Solrj#Directly_adding_POJOs_to_Solr[annotated bean]
Expand Down Expand Up @@ -110,7 +110,7 @@ from("direct:search")
<setHeader name="CamelSolrOperation">
<constant>INSERT</constant>
</setHeader>
<setHeader name="SolrField.id">
<setHeader name="CamelSolrField.id">
<simple>${body}</simple>
</setHeader>
<to uri="solr://localhost:8983/solr"/>
Expand All @@ -136,8 +136,8 @@ delete routes and then call the commit route.

[source,java]
-----------------------------------------------
template.sendBodyAndHeader("direct:insert", "1234", "SolrParam.commit", true);
template.sendBodyAndHeader("direct:delete", "1234", "SolrParam.commit", true);
template.sendBodyAndHeader("direct:insert", "1234", "CamelSolrParam.commit", true);
template.sendBodyAndHeader("direct:delete", "1234", "CamelSolrParam.commit", true);
template.sendBody("direct:search", "id:1234");
-----------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public interface SolrConstants {
@Metadata(description = "The content type is used to identify the type when inserting files.", javaType = "String")
String PARAM_CONTENT_TYPE = Exchange.CONTENT_TYPE;

String HEADER_FIELD_PREFIX = "SolrField.";
String HEADER_PARAM_PREFIX = "SolrParam.";
String HEADER_FIELD_PREFIX = "CamelSolrField.";
String HEADER_PARAM_PREFIX = "CamelSolrParam.";

String PROPERTY_ACTION_CONTEXT = "SolrActionContext";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public boolean process(Exchange exchange, AsyncCallback callback) {
? message.getHeader(SolrConstants.PARAM_REQUEST_HANDLER, String.class)
: configuration.getRequestHandler();

// Retrieve all SolrParams: SolrParams header and SolrParam.xxx headers
// Retrieve all SolrParams: SolrParams header and CamelSolrParam.xxx headers
ModifiableSolrParams modifiableSolrParams = getAndGroupedSolrParams(message);
boolean hasSolrParams = modifiableSolrParams.size() > 0;

Expand Down Expand Up @@ -130,7 +130,7 @@ private static ModifiableSolrParams getAndGroupedSolrParams(Message message) {
ModifiableSolrParams modifiableSolrParams = solrParams instanceof ModifiableSolrParams
? (ModifiableSolrParams) solrParams
: new ModifiableSolrParams(solrParams);
// add possible headers that start with "SolrParam." prefix
// add possible headers that start with "CamelSolrParam." prefix
message.getHeaders().entrySet().stream()
.filter(entry -> entry.getKey().startsWith(SolrConstants.HEADER_PARAM_PREFIX))
.forEach(entry -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,14 @@ private static UpdateRequest createUpdateRequestForInsert(Object body, Exchange
docs.ifPresent(updateRequest::add);
return updateRequest;
}
// Map: gather solr fields from body and merge with solr fields from headers (gathered from SolrField.xxx headers)
// Map: gather solr fields from body and merge with solr fields from headers (gathered from CamelSolrField.xxx headers)
// The header solr fields have priority
Map<String, Object> map = new LinkedHashMap<>(getMapFromBody(body));
map.putAll(getMapFromHeaderSolrFields(exchange));
if (!map.isEmpty()) {
body = map;
}
// Map: translate to SolrInputDocument (possibly gathered from SolrField.xxx headers
// Map: translate to SolrInputDocument (possibly gathered from CamelSolrField.xxx headers
Optional<SolrInputDocument> doc = getOptionalSolrInputDocumentFromMap(body, exchange);
if (doc.isPresent()) {
updateRequest.add(doc.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void testInsertSolrInputDocumentList() {
public void testInsertStreaming() {
// TODO rename method
ExchangeBuilder builder = ExchangeBuilder.anExchange(camelContext())
.withHeader("SolrField.id", "MA147LL/A");
.withHeader("CamelSolrField.id", "MA147LL/A");
executeInsert(builder.build());

QueryResponse response = executeSolrQuery("id:MA147LL/A");
Expand All @@ -202,7 +202,7 @@ public void testInsertStreaming() {
@Test
public void indexSingleDocumentOnlyWithId() {
ExchangeBuilder builder = ExchangeBuilder.anExchange(camelContext())
.withHeader("SolrField.id", "MA147LL/A");
.withHeader("CamelSolrField.id", "MA147LL/A");
executeInsert(builder.build());

// Check things were indexed.
Expand All @@ -223,9 +223,9 @@ public void caughtSolrExceptionIsHandledElegantly() {
public void setHeadersAsSolrFields() {
ExchangeBuilder builder = ExchangeBuilder.anExchange(camelContext())
.withBody("Body is ignored")
.withHeader("SolrField.id", "MA147LL/A")
.withHeader("SolrField.name_s", "Apple 60 GB iPod with Video Playback Black")
.withHeader("SolrField.manu_s", "Apple Computer Inc.");
.withHeader("CamelSolrField.id", "MA147LL/A")
.withHeader("CamelSolrField.name_s", "Apple 60 GB iPod with Video Playback Black")
.withHeader("CamelSolrField.manu_s", "Apple Computer Inc.");
executeInsert(builder.build());

QueryResponse response = executeSolrQuery("id:MA147LL/A");
Expand All @@ -242,8 +242,8 @@ public void setMultiValuedFieldInHeader() {
String[] categories = { "electronics", "apple" };
ExchangeBuilder builder = ExchangeBuilder.anExchange(camelContext())
.withBody("Test body for iPod.")
.withHeader("SolrField.id", "MA147LL/A")
.withHeader("SolrField.cat", categories);
.withHeader("CamelSolrField.id", "MA147LL/A")
.withHeader("CamelSolrField.cat", categories);
executeInsert(builder.build());

// Check things were indexed.
Expand All @@ -259,9 +259,9 @@ public void setMultiValuedFieldInHeader() {
@Test
public void indexDocumentsAndThenCommit() {
ExchangeBuilder builder = ExchangeBuilder.anExchange(camelContext())
.withHeader("SolrField.id", "MA147LL/A")
.withHeader("SolrField.name", "Apple 60 GB iPod with Video Playback Black")
.withHeader("SolrField.manu", "Apple Computer Inc.");
.withHeader("CamelSolrField.id", "MA147LL/A")
.withHeader("CamelSolrField.name", "Apple 60 GB iPod with Video Playback Black")
.withHeader("CamelSolrField.manu", "Apple Computer Inc.");
executeInsert(builder.build(), false);

QueryResponse response = executeSolrQuery("*:*");
Expand All @@ -279,7 +279,7 @@ public void indexDocumentsAndThenCommit() {
public void indexWithAutoCommit() {
// new exchange - not autocommit route
ExchangeBuilder builder = ExchangeBuilder.anExchange(camelContext())
.withHeader("SolrField.content", "NO_AUTO_COMMIT");
.withHeader("CamelSolrField.content", "NO_AUTO_COMMIT");
executeInsert(DEFAULT_START_ENDPOINT, builder.build(), false);
// not committed
QueryResponse response = executeSolrQuery("*:*");
Expand All @@ -292,7 +292,7 @@ public void indexWithAutoCommit() {

// new exchange - autocommit route
builder = ExchangeBuilder.anExchange(camelContext())
.withHeader("SolrField.content", "AUTO_COMMIT");
.withHeader("CamelSolrField.content", "AUTO_COMMIT");
executeInsert(DEFAULT_START_ENDPOINT_AUTO_COMMIT, builder.build(), false);
// should be committed
response = executeSolrQuery("*:*");
Expand All @@ -303,9 +303,9 @@ public void indexWithAutoCommit() {
@Test
public void invalidSolrParametersAreIgnored() {
ExchangeBuilder builder = ExchangeBuilder.anExchange(camelContext())
.withHeader("SolrField.id", "MA147LL/A")
.withHeader("SolrField.name", "Apple 60 GB iPod with Video Playback Black")
.withHeader("SolrParam.invalid-param", "this is ignored");
.withHeader("CamelSolrField.id", "MA147LL/A")
.withHeader("CamelSolrField.name", "Apple 60 GB iPod with Video Playback Black")
.withHeader("CamelSolrParam.invalid-param", "this is ignored");
executeInsert(builder.build());

QueryResponse response = executeSolrQuery("*:*");
Expand Down Expand Up @@ -374,9 +374,9 @@ public void indexDocumentsToCSVUpdateHandlerWithParameters() {
ExchangeBuilder builder = ExchangeBuilder.anExchange(camelContext())
.withBody(new File("src/test/resources/data/books.csv"))
.withHeader(SolrConstants.PARAM_CONTENT_TYPE, "text/csv")
.withHeader("SolrParam.fieldnames", "id,cat,name,price,inStock,author_t,series_t,sequence_i,genre_s")
.withHeader("SolrParam.skip", "cat,sequence_i,genre_s")
.withHeader("SolrParam.skipLines", 1);
.withHeader("CamelSolrParam.fieldnames", "id,cat,name,price,inStock,author_t,series_t,sequence_i,genre_s")
.withHeader("CamelSolrParam.skip", "cat,sequence_i,genre_s")
.withHeader("CamelSolrParam.skipLines", 1);
executeInsert(builder.build());
QueryResponse response = executeSolrQuery("*:*");
assertEquals(0, response.getStatus());
Expand All @@ -392,7 +392,7 @@ public void indexPDFDocumentToExtractingRequestHandler() {

ExchangeBuilder builder = ExchangeBuilder.anExchange(camelContext())
.withBody(new File("src/test/resources/data/tutorial.pdf"))
.withHeader("SolrParam.literal.id", "tutorial.pdf");
.withHeader("CamelSolrParam.literal.id", "tutorial.pdf");
executeInsert(builder.build());

QueryResponse response = executeSolrQuery("*:*");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected void solrInsertTestEntry() {
protected void solrInsertTestEntry(String id) {
Map<String, Object> headers = new HashMap<>();
headers.put(SolrConstants.PARAM_OPERATION, SolrConstants.OPERATION_INSERT);
headers.put("SolrField.id", id);
headers.put("CamelSolrField.id", id);
template.sendBodyAndHeaders(DEFAULT_START_ENDPOINT, "", headers);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,37 @@ As a consequence, the generated Endpoint DSL header accessors on
* `linkType()` -> `jiraLinkType()`
* `minutesSpent()` -> `jiraMinutesSpent()`

=== camel-solr

The two Exchange header prefix constants in `SolrConstants` have been renamed to
follow the Camel naming convention already used by the other constants in the
same file (which were renamed in 4.10 under CAMEL-21697). The Java field names
are unchanged; only the prefix string values have changed:

[options="header"]
|===
| Constant | Previous value | New value
| `SolrConstants.HEADER_FIELD_PREFIX` | `SolrField.` | `CamelSolrField.`
| `SolrConstants.HEADER_PARAM_PREFIX` | `SolrParam.` | `CamelSolrParam.`
|===

Routes that reference the constants symbolically (for example
`setHeader(SolrConstants.HEADER_FIELD_PREFIX + "id", ...)`) continue to work
without changes. Routes that set the headers by their literal string value
(for example `setHeader("SolrField.id", ...)` or
`setHeader("SolrParam.commit", ...)`) must be updated to use the new prefix
(`CamelSolrField.id`, `CamelSolrParam.commit`).

Because the renamed prefixes now begin with `Camel`, they are stripped by the
standard transport `HeaderFilterStrategy` (`HttpHeaderFilterStrategy`, etc.)
when crossing a transport boundary, by design — `Camel*` headers are
framework-internal and are not propagated over the wire. Routes that bridge an
external transport (HTTP, JMS, ...) into a `solr:` producer and want to drive
Solr document fields or query parameters from a header supplied by the sender
must therefore carry the value in a non-`Camel`-prefixed application header and
map it to the appropriate `CamelSolrField.*` / `CamelSolrParam.*` header in the
route between the transport `from` and the `solr:` `to`.

== Upgrading from 4.14.5 to 4.14.6

=== camel-platform-http-main
Expand Down
Loading