# Filtering based on creation\_time requires index\_timestamps

**URL:** <https://forum.weaviate.io/t/filtering-based-on-creation-time-requires-index-timestamps/9090>\
**Category:** Support\
**Created:** [December 4, 2024, 1:09pm UTC](https://forum.weaviate.io/t/filtering-based-on-creation-time-requires-index-timestamps/9090 "2024-12-04T13:09:17Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![abdimussa](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/abdimussa/32/124_2.png) [@abdimussa](https://forum.weaviate.io/u/abdimussa)\
**Post date:** [December 4, 2024, 1:09pm UTC](https://forum.weaviate.io/t/filtering-based-on-creation-time-requires-index-timestamps/9090/1 "2024-12-04T13:09:17Z")

</div>

### Description

I wanted to perform a search using creation\_time in weaviate, and it requires timestamp index to be added

```auto
jobss =jps.get_objects(
    filters=Filter.by_creation_time().greater_than(filter_time),
    metadata={'creation_time':True}, limit=80
    )

```

With this error outputted:

```auto
Timestamps must be indexed to be filterable! Add
`IndexTimestamps: true` to the InvertedIndexConfig in JobProfile"

```

How to update the collection definition so that it supports filters on creation\_time. I’m using weaviate v4 python client.

### Server Setup Information

- Weaviate Server Version: 1.25.3
- Deployment Method: docker
- Client Language and Version: Python and version 4.6.5

---

<div class="post-metadata">

**Author:** ![Shahin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/shahin/32/7944_2.png) [@Shahin](https://forum.weaviate.io/u/Shahin)\
**Post date:** [December 4, 2024, 4:38pm UTC](https://forum.weaviate.io/t/filtering-based-on-creation-time-requires-index-timestamps/9090/2 "2024-12-04T16:38:30Z")

</div>

Hi @abdimussa,

Have you enabled the `indexTimestamps`?

> **[Collection definition | Weaviate](https://weaviate.io/developers/weaviate/config-refs/schema#indextimestamps)**
>
> Schema Configuration in Weaviate

Example:

> import weaviate.classes.config as wcc  
> import weaviate.classes as wvc
> 
> > client.collections.create(  
> > name=“Test\_time”,  
> > vectorizer\_config=wcc.Configure.Vectorizer.text2vec\_openai(),  
> > inverted\_index\_config=wcc.Configure.inverted\_index(  
> > index\_timestamps = True  
> > ),  
> > properties=[  
> > wcc.Property(  
> > name=“question”,  
> > data\_type=wcc.DataType.TEXT,  
> > tokenization=wcc.Tokenization.WORD,  
> > ),  
> > wcc.Property(  
> > name=“answer”,  
> > data\_type=wcc.DataType.TEXT,  
> > tokenization=wcc.Tokenization.FIELD,  
> > )  
> > ],
> > 
> > )

---

<div class="post-metadata">

**Author:** ![abdimussa](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/abdimussa/32/124_2.png) [@abdimussa](https://forum.weaviate.io/u/abdimussa)\
**Post date:** [December 4, 2024, 5:05pm UTC](https://forum.weaviate.io/t/filtering-based-on-creation-time-requires-index-timestamps/9090/3 "2024-12-04T17:05:52Z")

</div>

Hi @Shahin. I haven’t enabled it during the creation of the collection. I want to update the collection currently. Is there a way to do that?

---

<div class="post-metadata">

**Author:** ![Shahin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/shahin/32/7944_2.png) [@Shahin](https://forum.weaviate.io/u/Shahin)\
**Post date:** [December 5, 2024, 4:04pm UTC](https://forum.weaviate.io/t/filtering-based-on-creation-time-requires-index-timestamps/9090/4 "2024-12-05T16:04:33Z")

</div>

Good evening @abdimussa,

You will need to re-index the collection with:

> inverted\_index\_config=wcc.Configure.inverted\_index(
> 
> index\_timestamps=True
> 
> )

index\_timestamps is an immutable parameter that must be initialized at the schema creation.

Furthermore, I would like to share that we have a mutability list available here:

> **[Collection definition | Weaviate](https://weaviate.io/developers/weaviate/config-refs/schema#mutability)**
>
> Schema Configuration in Weaviate

Some parameters are mutable after you create your collection.

---

<div class="post-metadata">

**Author:** ![abdimussa](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/abdimussa/32/124_2.png) [@abdimussa](https://forum.weaviate.io/u/abdimussa)\
**Post date:** [December 5, 2024, 5:44pm UTC](https://forum.weaviate.io/t/filtering-based-on-creation-time-requires-index-timestamps/9090/5 "2024-12-05T17:44:26Z")

</div>

Good evening @Shahin, so this means I’ll need to recreate the collection?

---

<div class="post-metadata">

**Author:** ![Shahin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/shahin/32/7944_2.png) [@Shahin](https://forum.weaviate.io/u/Shahin)\
**Post date:** [December 5, 2024, 6:25pm UTC](https://forum.weaviate.io/t/filtering-based-on-creation-time-requires-index-timestamps/9090/6 "2024-12-05T18:25:52Z")

</div>

@abdimussa yes that’s correct.

---

<div class="post-metadata">

**Author:** ![abdimussa](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/abdimussa/32/124_2.png) [@abdimussa](https://forum.weaviate.io/u/abdimussa)\
**Post date:** [December 5, 2024, 7:00pm UTC](https://forum.weaviate.io/t/filtering-based-on-creation-time-requires-index-timestamps/9090/7 "2024-12-05T19:00:18Z")

</div>

@Shahin ok thank you. I’d appreciate it if you can share a resource on how to do that efficiently.

---

<div class="post-metadata">

**Author:** ![Shahin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/shahin/32/7944_2.png) [@Shahin](https://forum.weaviate.io/u/Shahin)\
**Post date:** [December 5, 2024, 9:07pm UTC](https://forum.weaviate.io/t/filtering-based-on-creation-time-requires-index-timestamps/9090/8 "2024-12-05T21:07:12Z")

</div>

@abdimussa,

Absolutely, I am more than happy to ensure you are well supported. Before sharing some snippets with you to re-use, is there anything specific you’re using or would like to use in your cluster? If so, I can prepare some snippets that cover everything, so you won’t have to face that again.

Otherwise, please make sure you go through the mutability list to familiarize yourself with what can be re-configured after creation.

If you’d like, you can share your schema creation method with me, and I’d be happy to tweak it programmatically for you as well.

---

<div class="post-metadata">

**Author:** ![abdimussa](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/abdimussa/32/124_2.png) [@abdimussa](https://forum.weaviate.io/u/abdimussa)\
**Post date:** [December 6, 2024, 8:55am UTC](https://forum.weaviate.io/t/filtering-based-on-creation-time-requires-index-timestamps/9090/9 "2024-12-06T08:55:21Z")

</div>

@Shahin let’s take the below as an example.

```auto
client = weaviate.connect_to_custom(
                http_host=valid_url,
                http_port="443",
                http_secure=True,
                grpc_host=valid_url,
                grpc_port="50051",
                grpc_secure=True,
                auth_credentials=auth_config,
                headers=headers,
                additional_config=AdditionalConfig(
                    timeout=Timeout(init=30, query=60, insert=120), 
                ),
                skip_init_checks=True 
            )

client.collections.create(
    "ArticleMetadata",
    properties=[
        Property(name="metadata", data_type=DataType.TEXT),
    ],
    vectorizer_config=wc.Configure.Vectorizer.text2vec_openai(
                model="text-embedding-3-small",
            ),
    generative_config=wc.Configure.Generative.openai(),
)

client.collections.create(
    "Article",
    properties=[
        Property(name="title", data_type=DataType.TEXT),
        Property(name="body", data_type=DataType.TEXT),
    ],
    references=[
                wc.ReferenceProperty(
                    name="hasMetaData",
                    target_collection="ArticleMetaData"
                )
            ],        
    vectorizer_config=wc.Configure.Vectorizer.text2vec_openai(
                model="text-embedding-3-small",
            ),
    generative_config=wc.Configure.Generative.openai(),
)

```

---

<div class="post-metadata">

**Author:** ![Shahin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/shahin/32/7944_2.png) [@Shahin](https://forum.weaviate.io/u/Shahin)\
**Post date:** [December 6, 2024, 5:30pm UTC](https://forum.weaviate.io/t/filtering-based-on-creation-time-requires-index-timestamps/9090/10 "2024-12-06T17:30:03Z")

</div>

@abdimussa

> from weaviate.classes.config import Configure  
> from weaviate.classes.config import Property, DataType, ReferenceProperty, Tokenization
> 
> client.collections.create(  
> name=“Article”,  
> vectorizer\_config=Configure.Vectorizer.text2vec\_openai(model=“text-embedding-3-small”),  
> generative\_config=Configure.Generative.openai(),  
> inverted\_index\_config=Configure.inverted\_index(  
> index\_timestamps = True  
> ),  
> replication\_config=Configure.replication(factor=3, async\_enabled=True),  
> properties=[  
> Property(  
> name=“title”,  
> data\_type=DataType.TEXT,  
> tokenization=Tokenization.WORD,  
> ),  
> Property(  
> name=“body”,  
> data\_type=DataType.TEXT,  
> tokenization=Tokenization.FIELD,  
> )  
> ],  
> references=[  
> ReferenceProperty(  
> name=“hasMetaData”,  
> target\_collection=“ArticleMetaData”  
> )  
> ]  
> )

---

<div class="post-metadata">

**Author:** ![abdimussa](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/abdimussa/32/124_2.png) [@abdimussa](https://forum.weaviate.io/u/abdimussa)\
**Post date:** [December 12, 2024, 4:23pm UTC](https://forum.weaviate.io/t/filtering-based-on-creation-time-requires-index-timestamps/9090/11 "2024-12-12T16:23:47Z")

</div>

@Shahin Thank you for your response. However, I wanted to see more on the data migration part from my old collection to the new one where the index\_timestamp is set to true. I’m facing issue with how I can migrate the references of each object.

The below is a sample code I’ve got:

```auto
def migrate_data(collection_src:Collection, collection_tgt:Collection):

    with collection_tgt.batch.fixed_size(batch_size=20) as batch:
        for q in tqdm(collection_src.iterator(include_vector=True,return_references=QueryReference(
                link_on="hasMetaData",
                return_properties=["metadata"]
            ))):
            batch.add_object(
                properties=q.properties,
                vector=q.vector["default"],
                uuid=q.uuid,
            )
            

    return True

```

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [December 19, 2024, 3:42pm UTC](https://forum.weaviate.io/t/filtering-based-on-creation-time-requires-index-timestamps/9090/12 "2024-12-19T15:42:19Z")

</div>

hi @abdimussa !!

You can run thru all objects using the [iterator](https://weaviate.io/developers/weaviate/manage-data/read-all-objects) api, and then migrate the cross references [using this](https://weaviate.io/developers/weaviate/manage-data/cross-references#add-a-one-way-cross-reference):

```python
questions = client.collections.get("JeopardyQuestion")

questions.data.reference_add(
    from_uuid=question_obj_id,
    from_property="hasCategory",
    to=category_obj_id
)

```

Let me know if that helps!

Thanks!

---

<div class="post-metadata">

**Author:** ![abdimussa](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/abdimussa/32/124_2.png) [@abdimussa](https://forum.weaviate.io/u/abdimussa)\
**Post date:** [December 20, 2024, 12:28pm UTC](https://forum.weaviate.io/t/filtering-based-on-creation-time-requires-index-timestamps/9090/13 "2024-12-20T12:28:05Z")

</div>

@DudaNogueira, thank you, this is helpful.
