I am trying get few records by filtering odata using a filter where status not equals to bad and poor and id= 105 and id= 106
http://mywebsite.com/testService.svc/Details?$top=10&$filter=(Status ne 'Bad' and Status ne 'poor' and Id eq 105 and Id eq 106)
What was my mistake this show 0 records even there are related records. Is my syntax wrong?
I assuming that your ID property is a primary key. So there will never be a data set that matches both IDs but you are searching for it with and. Try to change your query to:
http://mywebsite.com/testService.svc/Details?$top=10&$filter=(Status ne 'Bad' and Status ne 'poor' and (Id eq 105 or Id eq 106))
Related
I have a builder query that pulls info depending on info entered. The main tables are hotels and rates. The user can sort the results with price high to low and price low to high. I need to put all results that return 0 ( some rate date ranges have place holders with 0 as the price ) or hotels that dont have rates at the end of the results no matter what. How can I handle making those both show up at the end regardless of the sorting. I have the below as where I am now but this doesnt handle things if it doesnt exist only if its 0 but it also doesnt handle putting the results at the end.
One more thing, Im using pagination or else I would just do a foreach and reorder them.
$builder->select('hotels.id','hotels.main_image','hotels.sleeps','hotels.bathrooms','hotels.destination_id','hotels.hotel_name','hotels.slug','hotels.summary','hotels.sleeps','hotels.bedrooms',DB::raw('CASE WHEN max(rates.nightly_rate) = 0 THEN NULL ELSE max(rates.nightly_rate) END AS price_high'),DB::raw('CASE WHEN min(rates.nightly_rate) = 0 THEN NULL ELSE min(rates.nightly_rate) END AS price_low')
->leftJoin('rates', 'hotels.id', '=', 'rates.hotels_id');
It is possible to enforce records where nightly_rate is 0 or null to be ordered last in order by clause.
A clause like rates.nightly_rates = 0 or rates.nightly_rate IS NULL ASC will ensure that matched records where this condition is FALSE are ordered first before records where it is TRUE.
$builder
->
//...
->orderByRaw('rates.nightly_rate = 0 OR rates.nightly_rate IS NULL ASC');
I am having troubles deleting variations of a listing. I am sending a DELETE request to /listings/123456789/variations/200?value=2714985994 (where 200 is the property_id and 2714985994 is the value_id), but the response is:
"Property ID 200 and value ID 2714985994 is not a valid combination for this listing"
Does anybody have any idea how to delete a variation?
/listings/123456789/variations/200?value=2714985994
This you provide value as integer but ETSY documents allow string value
For example 200 is property_id is color and value is Black
Your url like this
/listings/123456789/variations/200?value=Black
I am using blaze for querying data from csv and json. I just need to query a record where id is equal to the specified id? Is it possible.
city = city[city.ID = 1]
While trying to execute the above code it shows
SyntaxError: invalid syntax
That works, but in your case you'd need to have a field named ID, it's not a magical field. The following works, but only because there's a column explicitly named id in accounts.csv:
from blaze import Data
from blaze.utils import example
accounts = Data(example('accounts.csv')
accounts[accounts.id == 2]
# id name balance
# 1 2 Bob 200
I have one query in service class
PageRequest page = new PageRequest(pageNo,batchSize , new Sort(new Order(Direction.ASC, "Id")));
Page pPage = this.pRepository.findByStatusAndParentPId( Status.PENDING, -1, page);
where batchSize=500
In repository we have following code:
#Query("select p from Part p where p.succeedOn IS NOT NULL and p.Status=? and p.parentId=?")
Page<Payment> findByStatusAndParentId( String status, Integer parentId, Pageable p);
Now flow is like this, i want to fetch 500 rows everytime whose status is pending and then i need to process it and need to change the status to success. So using Pageable is giving me wrong result because , suppose it fetch first 500 rows whose status is pending , it processed it and changed the status to success, now it will again make sql query and will fetch row from 501 to 1000 , but actually row 1 to 500 also have status pending as older processed rows status changed to success, so they will not be covered in sql query.
Now to solve this i want to do pagenation with from last row of last fetched Id , say last time it fetched from 100 to 600, then i want to give 601 as argument and want to fetch all rows onward..... hopefully i am able to explain my answer. Limit in query do not work in JPA.
Thanks
I think you can just keep fetching page 1. Assuming each batch is processed in its own transaction, then by the time you process the second batch, page 1 should give you the next 500 un-processed rows
We are using Cassandra for log collecting.
About 150,000 - 250,000 new records per hour.
Our column family has several columns like 'host', 'errorlevel', 'message', etc and special indexed column 'indexTimestamp'.
This column contains time rounded to hours.
So, when we want to get some records, we use get_indexed_slices() with first IndexExpression by indexTimestamp ( with EQ operator ) and then some other IndexExpressions - by host, errorlevel, etc.
When getting records just by indexTimestamp everything works fine.
But, when getting records by indexTimestamp and, for example, host - cassandra works for long ( more than 15-20 seconds ) and throws timeout exception.
As I understand, when getting records by indexed column and non-indexed column, Cassandra firstly gets all records by indexed column and than filters them by non-indexed columns.
So, why Cassandra does it so slow? By indexTimestamp there are no more than 250,000 records. Isn't it possible to filter them at 10 seconds?
Our Cassandra cluster is running on one machine ( Windows 7 ) with 4 CPUs and 4 GBs memory.
You have to bear in mind that Cassandra is very bad with this kind of queries. Indexed columns queries are not meant for big tables. If you want to search for your data around this type of queries you have to tailor your data model around it.
In fact Cassandra is not a DB you can query. It is a key-value storage system. To understand that please go there and have a quick look: http://howfuckedismydatabase.com/
The most basic pattern to help you is bucket-rows and ranged range-slice-queries.
Let's say you have the object
user : {
name : "XXXXX"
country : "UK"
city : "London"
postal_code :"N1 2AC"
age : "24"
}
and of course you want to query by city OR by age (and & or is another data model yet).
Then you would have to save your data like this, assuming the name is a unique id :
write(row = "UK", column_name = "city_XXXX", value = {...})
AND
write(row = "bucket_20_to_25", column_name = "24_XXXX", value = {...})
Note that I bucketed by country for the city search and by age bracket for age search.
the range query for age EQ 24 would be
get_range_slice(row= "bucket_20_to_25", from = "24-", to = "24=")
as a note "minus" == "under_score" - 1 and "equals" == "under_score" + 1, giving you effectively all the columns that start with "24_"
This also allow you to query for age between 21 and 24 for example.
hope it was useful