Skip to content

Commit 8321e4d

Browse files
committed
Fix naming issue and leftover logging call
Signed-off-by: Łukasz Jernaś <[email protected]>
1 parent 76752cf commit 8321e4d

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

auto-configurations/models/chat/memory/spring-ai-autoconfigure-model-chat-memory-mongodb/src/main/java/org/springframework/ai/model/chat/memory/mongodb/autoconfigure/MongoDbChatMemoryIndexCreator.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
* main index on the conversationId and timestamp fields, and a TTL index on the timestamp
3333
* field if the TTL is set in properties.
3434
*
35-
* @see MongoDbChatMemoryProperties
3635
* @author Łukasz Jernaś
36+
* @see MongoDbChatMemoryProperties
3737
* @since 1.0.0
3838
*/
3939
@Component
40-
@ConditionalOnProperty(value = "spring.ai.chat.memory.mongodb.create-indexes", havingValue = "true")
40+
@ConditionalOnProperty(value = "spring.ai.chat.memory.mongodb.create-indices", havingValue = "true")
4141
public class MongoDbChatMemoryIndexCreator {
4242

4343
private static final Logger logger = LoggerFactory.getLogger(MongoDbChatMemoryIndexCreator.class);
@@ -60,14 +60,12 @@ public void initIndicesAfterStartup() {
6060
.ensureIndex(new Index().on("conversationId", Sort.Direction.ASC).on("timestamp", Sort.Direction.DESC));
6161

6262
createOrUpdateTtlIndex();
63-
6463
}
6564

6665
private void createOrUpdateTtlIndex() {
6766
if (!this.mongoDbChatMemoryProperties.getTtl().isZero()) {
6867
// Check for existing TTL index
6968
mongoTemplate.indexOps(Conversation.class).getIndexInfo().forEach(idx -> {
70-
logger.error("Index info: {}", idx);
7169
if (idx.getExpireAfter().isPresent()
7270
&& !idx.getExpireAfter().get().equals(this.mongoDbChatMemoryProperties.getTtl())) {
7371
logger.warn("Dropping existing TTL index, because TTL is different");

auto-configurations/models/chat/memory/spring-ai-autoconfigure-model-chat-memory-mongodb/src/main/java/org/springframework/ai/model/chat/memory/mongodb/autoconfigure/MongoDbChatMemoryProperties.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class MongoDbChatMemoryProperties {
3333
* If the indexes should be automatically created on app startup. Note: Changing the
3434
* TTL value will drop the TTL index and recreate it.
3535
*/
36-
private boolean createIndexes = false;
36+
private boolean createIndices = false;
3737

3838
/**
3939
* The time to live (TTL) for the conversation documents in the database. The default
@@ -49,12 +49,12 @@ public void setTtl(Duration ttl) {
4949
this.ttl = ttl;
5050
}
5151

52-
public boolean isCreateIndexes() {
53-
return createIndexes;
52+
public boolean isCreateIndices() {
53+
return createIndices;
5454
}
5555

56-
public void setCreateIndexes(boolean createIndexes) {
57-
this.createIndexes = createIndexes;
56+
public void setCreateIndices(boolean createIndices) {
57+
this.createIndices = createIndices;
5858
}
5959

6060
}

auto-configurations/models/chat/memory/spring-ai-autoconfigure-model-chat-memory-mongodb/src/test/java/org/springframework/ai/model/chat/memory/mongodb/autoconfigure/MongoDbChatMemoryPropertiesTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@ public class MongoDbChatMemoryPropertiesTests {
2828
void defaultValues_set() {
2929
var properties = new MongoDbChatMemoryProperties();
3030
assertThat(properties.getTtl()).isEqualTo(Duration.ZERO);
31-
assertThat(properties.isCreateIndexes()).isFalse();
31+
assertThat(properties.isCreateIndices()).isFalse();
3232
}
3333

3434
@Test
3535
void overrideValues() {
3636
var properties = new MongoDbChatMemoryProperties();
3737
properties.setTtl(Duration.ofMinutes(1));
38-
properties.setCreateIndexes(true);
38+
properties.setCreateIndices(true);
3939

4040
assertThat(properties.getTtl()).isEqualTo(Duration.ofMinutes(1));
41-
assertThat(properties.isCreateIndexes()).isTrue();
41+
assertThat(properties.isCreateIndices()).isTrue();
4242
}
43+
4344
}

0 commit comments

Comments
 (0)