I have the following field in a my Solr 4 schema

<field name="id" type="string" indexed="true" stored="true" required="true" />
<dynamicField name="rank_*" type="int" indexed="true" stored="true" />

Which I can update atomically using below this which works great and leaves other fields alone

{"add":{"doc":{"id":"111","rank_350":{"set":"1"},"rank_391":{"set":"4"}}},
 "add":{"doc":{"id":"222","rank_350":{"set":"1"},"rank_391":{"set":"4"}}}}

Now I want to clear any existing ranks before updating with new ones, without having to query what they are first. If I use approach above and upated with just new rank the old two would remain there since update is atomic.

I have tried using the wildcard within one post or with other updates but solr thinks there is a field called rank_* rather than apply null setting to all ranks.

{"add":{"doc":{"id":"111","rank_*":{"set":"null"}}}

How can I apply an update to all rank_* dynamic fields?

Reason is I don't want to have to query first to see what was there before as I will be batch updating up to 200 at one time (this can be done in one post). If I had to query that would be 201 posts rather than 1, or changing my event to know what had been removed which is also difficult.

有帮助吗?

解决方案

That I know of, the only field-related features in Solr that support wildcards are the fl parameter, dynamicField, and copyField. Anything else, which includes all forms of indexing, can only reference one field at a time. There is no way as far as I know to do exactly what you're trying to do.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top