Problem sorting companies with search function

Hi guys!
During the last week I am having problems with the API when I try to get the companies.
I have built an incremental pipeline with python API, searching only the companies with the lastmodifieddate greater than my current one storaged in my database.Once a week we make a total load and the last Sunday we realized that we have much less records. Testing the code and reviewing the outputs we saw that the filters are not working well for companies.We have a search by lastmodifieddate order by lastmodifieddate and the results are usually ordered but in some outputs we have a recent value with the current date and after that record, everything continues normal.Example:Record1 → 2022-01-01 15:40
Record2 → 2022-01-01 18:40
Record3 → 2022-01-01 21:40
Record4 → 2024-02-21 10:40
Record5 → 2022-01-01 23:40
Record6 → 2022-01-02 00:40It is only happening with Companies. With other objects like Tickets, contacts or Deals it works perfectly.It is a function code example:

public_object_search_request = (
 self.hubspot_crm_mod.PublicObjectSearchRequest(
 properties=self.properties,
 limit=self.page_size,
 filter_groups=filter_groups,
 sorts=[
 {
 "propertyName": self.internal_id,
 "direction": "ASCENDING",
 }
 ],
 )
 )

It looks like sort function is not working properly to companies.
Someone has idea if there is a new bug or something?
Thanks for your attention!

Hey, @JGarcía5 :waving_hand: Thanks for flagging this. Can you confirm the issue is still occurring? If so, we can try to set up a quick test on my end and then get this to my internal resources.

Talk soon! — Jaycee

Hi @Jaycee_Lewis! Thanks for your attention.
Yes, we still have the issue. When we search and sort, there are some records not correctly sorted.
Regards!

Hi

Any solution for this ? We are also affected ?

It appears that the search API goes off of a secondary index, and the lastmodified timestamps are often not correctly refreshed. So you will see such out of order records when searching not just companies, but pretty much any object. We have the same problem with Contacts.

We are trying to workaround the issue by applying some statistical measures to outliers, and excluding them from pagination logic.