Skip to content

Add updateDocuments API which accept a query#12341

Merged
uschindler merged 2 commits intoapache:mainfrom
zhaih:main
Jun 1, 2023
Merged

Add updateDocuments API which accept a query#12341
uschindler merged 2 commits intoapache:mainfrom
zhaih:main

Conversation

@zhaih
Copy link
Contributor

@zhaih zhaih commented Jun 1, 2023

Description

Essentially just wire up updateDocuments(Query, Iterable<Document>) API, we could probably also add updateDocument for single document update, but I don't see a good reason to add that (except for completion) yet.

@uschindler
Copy link
Contributor

To me this looks fine, although I wonder why we needed a new Node<T> implementation, because deleteDocuments(Query) was already using a Query to delete. Or are those Node<T> instances only used for block indexing?

@uschindler uschindler merged commit 52ab167 into apache:main Jun 1, 2023
uschindler added a commit that referenced this pull request Jun 1, 2023
uschindler added a commit that referenced this pull request Jun 1, 2023
@uschindler
Copy link
Contributor

Sorry I pressed merge on wrong PR, so I reverted this.

Can you reopen this?

@uschindler
Copy link
Contributor

Of course you can also revert the revert, if that's applicable.

The change looks fine to me.

Copy link
Member

@mikemccand mikemccand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I left a couple minor comments. Thanks @zhaih.

if (random().nextBoolean()) {
writer.updateDocuments(new Term("id", id), Arrays.asList(doc, doc));
} else {
writer.updateDocuments(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also do this randomness in RandomIndexWriter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added to it, not sure whether that's the place in your mind?

@zhaih
Copy link
Contributor Author

zhaih commented Jun 2, 2023

I wonder why we needed a new Node implementation

@uschindler We previously have a Node<Query[]> impl as previous deleteDocuments took (Query...). I added that Node<Query> just to comply with the updateDocuments(Term delTerm...)

@zhaih
Copy link
Contributor Author

zhaih commented Jun 2, 2023

For some reason I cannot reopen this one, so I opened a new one #12346

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants