I'm trying to prepare some boolean query for SOLR engine to find some docs with specific locality field. Results that I get seems to be very weird. I cannot give exactly the same code I use because of security policy in my company but trying to simplify this query:
+(ddm/10973/locality_pl_PL:Gdańsk)
And this query return results as expected with Gdańsk city. But when I add some another condition like this:
+(+(ddm/10973/locality_pl_PL:Gdańsk)+(status:0))
In my results I get docs with city Gdańsk and Gdańsk-Wrzeszcz. Suddenly ":" seems to work as a 'like' not 'equals' as expected.
Does somebody know what could be the reason?
Related
Am i heading entirely down the wrong road?
Should this work?
I'm trying to build a query that restricts the selection based on a boolean
e.g. findByIdAndFieldIsTrue(id)
This always returns no values. If I narrow this and just do findById(id) i still get no results which seems odd. I have tried a number of permutations of Id & field in the method name but none work.
Entity {
#Id
String id
boolean field
}
interface EntityRepository BaseRepository, Repository {
findByIdAndFieldIsTrue(id)
}
I tried without the BaseRepository thinking maybe the findOne method was interfering but no luck.
Update:
After adding the logger suggested in the answer I can get the query
{"statement":"SELECT META(`mybucket`).id AS _ID, META(`mybucket`).cas AS _CAS, `mybucket`.* FROM `mybucket` WHERE (`id` = \"entity::9627ff50-531d-4191-a9dc-07b48ba77fe9\") AND `_class` = \"com.myrepo.repository.api.Entity\"","scan_consistency":"statement_plus"}
Edit: N1QL forces you to use the USE KEY construct to select by id... That will be much much harder to integrate, looks like the workaround is the easiest path (see below)
I think this is an overlook of query derivation on the #Id field. In Couchbase, that field maps to the document's key and isn't contained in the document's body, so the N1QL query needs to take that into account.
Can you activate logging for the query generation? There's an AbstractN1qlBasedQuery.class logger that will log the generated N1QL in DEBUG mode. It will allow us to see what the query looks like and confirm that a special step must be taken for the #Id field...
I know it wouldn't be as performant if deserialization is complex, but a workaround could be to use findOne and then check the field.
Got this to work with the following:
#Query("#{#n1ql.selectEntity} WHERE #{#n1ql.filter} AND META(#{#n1ql.bucket}).id IN $1")
List<Entity> findByIdIn(JsonArray ids);
To get the JsonArray from a list do the following:
import com.couchbase.client.java.document.json.JsonArray;
.
.
.
repository.findByIdIn(JsonArray.from(myList));
I noticed that when I query the API sometime I get results that are not really close to what I searched for.
Is there a method to get zero results and prevent false results?
I would like the search for "Babyface" and DO NOT get "baby smile" etc...
From SoundCloud:
Most endpoints will accept a q param which you can use to specify a keyword to search for in fields like title, username, description, etc. depending on the resource type.
So, not much detail there but they probably return results by relevance. I don't see anything about exact keyword searches.
What you can do is check the query results and make sure your search param actually exists in the track title, username, description, etc.
I am using the Facebook Ads API to try to filter out specific action target ids using the follwowing call:
(account-id)/reportstats?date_preset=yesterday&data_columns=["action_target_name","adgroup_id","adgroup_name","spend","actions","adgroup_objective"]&actions_group_by=["action_target_id", "action_destination"]&filters=[{"field": "action_target_id","type": "contains","value": 'insert id'}]
Every time I try to put in a specific ID, I get an empty data set back. Whenever I change the type to "not_contains", I get every piece of data returned. I've also tried the same with action_destination, but it keeps saying value needs to be numeric even though it a string.
It definitely seems like you can filter by action_target_id because when I tried to filter by something random, it told me that filter doesn't exist.
Can anyone help me please?
Unfortunately these values are nested under the actions fields of the results and filters only work on top level field values.
I was trying to using the like function in iReport 4.0.1. Checked online but none seem to work.
Currently trying to use:
where name LIKE'%$P!{px_name}%'
also tried
'%$P{px_name}%'
but when running the report it comes up saying 'No document'.
But when using where name =$P{px_name} it works perfectly fine.
Where clause will be same as you have used in first step which is :-
where name LIKE '%$P!{px_name}%'
But as you said report says 'The document has no pages' means the query is returning 0 row so just use the same string in LIKE and run the same query in database. Simplest solution is first run the query in database with LIKE operator , if it returns the rows in database then that should also work in iReport.
How can I write a query with ormlite instead of using .create or any other thing like that? Can you please show me how for this simple example :
SELECT name FROM client
EDIT since I can't answer myself :
I guess I had to search a little more , anyway I found how to do it with the QueryBuilder like this :
newDao.query(newDao.queryBuilder().where.eq("name",valueofname)
If someone knows how to write the full query that would be great , otherwise , I'll stick with this solution
How can I write a query with ormlite instead of using .create or any other thing like that?
Goodness, there are tons of documentation about how to do this on the ORMLite site. Here's the section on the query builder.
I'm not sure what you mean by "full query" but your example will work with some tweaks:
List<...> results = newDao.queryBuilder().where().eq("name",valueofname).query();
It does not make sense to just return the name since the Dao hierarchy is designed to return the specific Client object. If you just want the name the you can specify the name column only to return:
... clientDao.queryBuilder().selectColumns("name").where()...
That will return a list of Client objects with just the name field (and the id field if it exists) extracted from the database.
If you just want the name strings then you can use the RawResults feature.