Is there is any way to compare DateList with Date along with timestamp
eg I have indexed from_datetime in solr
"from_datetime":["2021-08-27T00:00:00Z", "2021-08-12T00:00:00Z", "2021-08-25T02:21:00Z"]
and user input is "2021-08-25T03:21:00Z".
How can I compare user input with from_datetime list
Related
I have a dynamodb table with following GSI:
partition key: scheduled_date which is a date string yyyy-mm-dd HH:MM:SS
range key: task_id which is an uuid
I would like to query for all items whose scheduled_date falls in a date, i.e. its prefix matches a string yyyy-mm-dd.
Is it possible without performing scan?
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.KeyConditions.html
You must provide the index partition key name and value as an EQ
condition.
In your case, you could consider using yyyy-mm-dd (or yyyymmdd) as the partition key to get all of the items that have that scheduled date.
You could keep task_id as the Range key OR you could use a prefix like HH:MM:SS:task_id. That way the tasks for a particular day would come back sorted by time. And if you really needed to you, could query them by time range.
There is also the alternative of using Global Secondary Indexes that can be utilized in a similar manner.
I'm creating an application similar to Twitter. In that I'm writing a query for the profile page. So when the user visits someone other users profile, he/she can view the tweets liked by that particular user. So for that my query is retrieving all such tweets liked by that user, along with total likes and comments on that tweet.
But an additional parameter I require is whether the current user has liked any of those tweets, and if yes, I want it to retrieve it as boolean True in my query so I can display it as liked in UI.
But I don't know how to achieve this part. Following is a sub-query from my main query
select l.tweet_id, count(*) as total_likes,
<insert here> as current_user_liked
from api_likes as l
INNER JOIN accounts_user ON l.liked_by_id = accounts_user.id
group by tweet_id
Is there an inbuilt function in postgres that can scan through the filtered rows and check whether current user id is present in liked_by_id. If so mark current_user_liked as True, else False.
You want to left outer join back into the api_likes table.
select l.tweet_id, count(*) as total_likes,
case
when lu.twee_id is null then false
else true
end as current_user_liked
from api_likes as l
INNER JOIN accounts_user ON l.liked_by_id = accounts_user.id
left join api_likes as lu on lu.tweet_id = l.tweet_id
and lu.liked_by_id = <current user id>
group by tweet_id
This will continue to bring in the rows you are seeing and will add a row for the lu alias on api_likes. If no such row exists matching the l.tweet_id and the current user's id, then the columns from the lu alias will be null.
I have a dynamo-db table with following schema
{
"id": String [hash key]
"type": String [range key]
}
I have a usecase where I need to fetch last 3 rows for a given id when type is unknown.
Your items need a timestamp attribute. Without that they can’t be sorted out filtered by time. Once you have that, you can define a local secondary index with the id as partition key and the timestamp as the sort key. You can then get the top three items from the index.
Find more information about DynamoDb’s Local Secondary Index here.
Add a field to store the timestamp to the schema
Use query to fetch all the records for the given key
Query always returns records sorted by range key, you cannot set a sort order (without changing table's schema), so, sort the records by timestamp in your code
Get top 3 records
If you have a lot of records, use filter expressions to drop extra results. E.g. if you know that latest records will always have a timestamp not older than a hour (day, week or so) you could filter older records.
I want to retrieve the values of order numbers and store it in a list. But the problem is I am able to fetch one not the other
ID Order
test#xyz.com 1-1155945200890<<<<able to fetch this
test1#xyz.com Hi how are you? 1-1155945200890<<<not able to fetch
By using below I am able to retrive the values to those column which do not have the junk data with it like that of just '1-1155945200890' but not from 'Hi how are you? 1-1155945200890'
To define feedback:
for user in users:
intent_name=data_to_analyse2.loc[data_to_analyse2['ID'] == user]
intent_list=list(intent_name['INTENTNAME'])
feedback=list(intent_name['Input'])
to fetch the match pattern:
pattern=re.compile("1[\-][\d]{2,15}")
pattern_list=list(filter(pattern.match, feedback))
How can I get all the values to the matching expression even if it has junk data associated with it
I have a table with separate date and time fields which are displayed in a ColdFusion CFGRID using CFGRIDCOLUMN. I'd like to be able to sort on date and then time. Is there a way to sort on more than one column? It sort of works by clicking to sort on the time column first and then the date column, but this is not reflected in the column header sort indicators.
I could combine the fields into a single datetime field and use Ext JS mask attributes to display the date and time in separate columns. Am I making it too hard for myself by having the date and time in separate fields?