Need to use Solr dismax handler but i have no q parameter??? - search

Hi
i am trying to make a solr Query using dismax handler but i have no q parameters because i have to match directly on fields..
hl.fragsize=200&mm=1&facet=on&facet.mincount=1&qf=text+&wt=json&hl=true&rows=50&fl=*+score&start=0&q=*:*&fq=jSFunT:("Fresher"+OR+"Developer+/+Programmer+/+Coder")&fq=jNMinEx:[2+TO+*]&fq=jNMaxEx:[2+TO+5]&fq=jNMinSal:[-1+TO+*]&fq=jNMaxSal:[-1+TO+-1]&bq=jSFunT:("Developer+/+Programmer+/+Coder")^1&bq=jSkill:(HTML)^2&bq=jCID:(41449)^8&bq=jJT:(Developer+)^8&bq=jLoc:(Mumbai-Thane+)^4&bq=jINDT:("IT(Software,+Dotcom,+Infra.Mgmt.%26+UI+Design)")^1
OR you can better understand it from below..
&mm=1
&qf=text
&wt=json
&hl=true
&rows=50
&fl=*+score
&start=0
&q=*:*
&fq=jSFunT:("Fresher"+OR+"Developer+/+Programmer+/+Coder")
&fq=jNMinEx:[2+TO+*]
&fq=jNMaxEx:[2+TO+5]
&fq=jNMinSal:[-1+TO+*]
&fq=jNMaxSal:[-1+TO+-1]
&bq=jSFunT:("Developer+/+Programmer+/+Coder")^1
&bq=jSkill:(HTML)^2
&bq=jCID:(41449)^8
&bq=jJT:(Java Developer)^8
&bq=jLoc:(Mumbai-Thane)^4
&bq=jINDT:("IT(Software,+Dotcom,+Infra.Mgmt.%26+UI+Design)")^1
Here all the "bq" will not work because the qt=dismax is not supplied if i use that then the whole query will fail
can i any one help me out i will be very thankful for this kindness

Have a look at the q.alt parameter, which lets you specify a fall back query:
q.alt=*:*
If you replace your q parameter with that one, dismax should play just fine.

Related

nodejs bigquery parameterised query inside IN() expression

I am trying to run a parameterised query using the npm module #google-cloud/bigquery.
Something like this:
SELECT * FROM myTable WHERE id IN (#ids);
I have no idea how bigQuery is expecting the parameter ids formatted.
My options.params look like something like this:
{ ids: '"1234", "4567"'}
But I don't get any result back. I know there are results, I can see them in bigquery and if I remove the parameter and just inject the string works just fine.
It seem pretty easy, but I can't figure out why it doesn't work, anyone who is willing to help me out?
Thank you in advance
Of course I found the solution as soon as I posted the question...
Thanks to this thread! Need to do some gymnastic...
So provided that the parameter is a string like:
'1234,5678'
We need to do:
WHERE id IN UNNEST(REGEXP_EXTRACT_ALL(#ids,"[0-9a-zA-Z]+"))
REGEXP_EXTRACT_ALL - returns an array
UNNEST - flattens the array for the IN clause as stated in the link above.

Multi insert inside a QueryFile

I'm able to generate query for multi inserts or update thanks to pg-promise helpers but I was wondering if I could follow the advice of the author and put all queries outside of my javascript code (See here https://github.com/vitaly-t/pg-promise/wiki/SQL-Files and here : https://github.com/vitaly-t/pg-promise-demo).
When I use the insert helpers, the return query looks like :
INSERT INTO "education"("candidate_id","title","content","degree","school_name","start_date","still_in","end_date","picture_url") VALUES('6','My degree','Business bachelor','Bachelor +','USC','2018-05-15T02:00:00.000+02:00'::date,false,null::date,null),('6','Another degree','Engineering','Master degree','City University','2018-05-15T02:00:00.000+02:00'::date,false,null::date,null)
The idea is that I don't know how many inserts I want to do at the same time, so it has to be dynamic.
The following code doesn't work as I'm passing an array of object instead of an object :
db.none(`INSERT INTO "education"("candidate_id","title","content","degree","school_name","start_date","still_in","end_date","picture_url")
VALUES($<candidate_id>, $<title>, $<content>, $<degree>, $<school_name>, $<start_date>, $<still_in>, $<end_date>, $<picture_url>)`, data)
This code spreads the object but is still not correct to make a proper query :
db.none(`INSERT INTO "education"("candidate_id","title","content","degree","school_name","start_date","still_in","end_date","picture_url")
VALUES($1:list)`,
[data])
Any idea ? Is it at least possible or in the case where I don't know how many records I want to insert in advance I have to call pgp.helpers everytime ?
You confuse static and dynamic SQL. SQL files are there for SQL queries that are mainly static, i.e. you still can inject dynamically a lot, but when most of the query is dynamic, there is no longer any point putting it into an SQL file.
And the helpers namespace is there for dynamic queries only. So you are asking about two separate things, to join things that do not need to be joined.

AEM Query builder exclude a folder in search

I need to create a query where the params are like:
queryParams.put("path", "/content/myFolder");
queryParams.put("1_property", "myProperty");
queryParams.put("1_property.operation", "exists");
queryParams.put("p.limit", "-1");
But, I need to exclude a certain path inside this blanket folder , say: "/content/myFolder/wrongFolder" and search in all other folders (whose number keeps on varying)
Is there a way to do so ? I didn't find it exactly online.
I also tried the unequals operation as the parent path is being saved in a JCR property, but still no luck. I actually need unlike to avoid all occurrences of the path. But there is no such thing:
path=/main/path/to/search/in
group.1_property=cq:parentPath
group.1_property.operation=unequals
group.1_property.value=/path/to/be/avoided
group.2_property=myProperty
group.2_property.operation=exists
group.p.or=true
p.limit=-1
This is an old question but the reason you got more results later lies in the way in which you have constructed your query. The correct way to write a query like this would be something like:
path=/main/path/where
property=myProperty
property.operation=exists
property.value=true
group.p.or=true
group.p.not=true
group.1_path=/main/path/where/first/you/donot/want/to/search
group.2_path=/main/path/where/second/you/donot/want/to/search
p.limit=-1
A couple of notes: your group.p.or in your last comment would have applied to all of your groups because they weren't delineated by a group number. If you want an OR to be applied to a specific group (but not all groups), you would use:
path=/main/path/where
group.1_property=myProperty
group.1_property.operation=exists
group.1_property.value=true
2_group.p.or=true
2_group.p.not=true
2_group.3_path=/main/path/where/first/you/donot/want/to/search
2_group.4_path=/main/path/where/second/you/donot/want/to/search
Also, the numbers themselves don't matter - they don't have to be sequential, as long as property predicate numbers aren't reused, which will cause an exception to be thrown when the QB tries to parse it. But for readability and general convention, they're usually presented that way.
I presume that your example was just thrown together for this question, but obviously your "do not search" paths would have to be children of the main path you want to search or including them in the query would be superfluous, the query would not be searching them anyway otherwise.
AEM Query Builder Documentation for 6.3
Hope this helps someone in the future.
Using QueryBuilder you can execute:
map.put("group.p.not",true)
map.put("group.1_path","/first/path/where/you/donot/want/to/search")
map.put("group.2_path","/second/path/where/you/donot/want/to/search")
Also I've checked PredicateGroup's class API and they provide a setNegated method. I've never used it myself, but I think you can negate a group and combine it into a common predicate with the path you are searching on like:
final PredicateGroup doNotSearchGroup = new PredicateGroup();
doNotSearchGroup.setNegated(true);
doNotSearchGroup.add(new Predicate("path").set("path", "/path/where/you/donot/want/to/search"));
final PredicateGroup combinedPredicate = new PredicateGroup();
combinedPredicate.add(new Predicate("path").set("path", "/path/where/you/want/to/search"));
combinedPredicate.add(doNotSearchGroup);
final Query query = queryBuilder.createQuery(combinedPredicate);
Here is the query to specify operator on given specific group id.
path=/content/course/
type=cq:Page
p.limit=-1
1_property=jcr:content/event
group.1_group.1_group.daterange.lowerBound=2019-12-26T13:39:19.358Z
group.1_group.1_group.daterange.property=jcr:content/xyz
group.1_group.2_group.daterange.upperBound=2019-12-26T13:39:19.358Z
group.1_group.2_group.daterange.property=jcr:content/abc
group.1_group.3_group.relativedaterange.property=jcr:content/courseStartDate
group.1_group.3_group.relativedaterange.lowerBound=0
group.1_group.2_group.p.not=true
group.1_group.1_group.p.not=true

Extract facets based on tags in Query Builder

I am trying to extract the facets using Query builder in AEM. My query is as below:
1_group.p.or=true
1_group.1_type=cq:Page
1_group.2_type=dam:Asset
2_group.p.or=true
2_group.1_path=/content
2_group.2_path=/content/dam
3_group.p.or=true
3_group.1_tagid=/etc/tags/geometrixx-outdoors/activity/biking
3_group.1_tagid.property=#jcr:content/cq:tags
3_group.2_tagid=/etc/tags/geometrixx-outdoors/activity/biking
3_group.2_tagid.property=#jcr:content/metadata/cq:tags
fulltext=text
p.limit=-1
The Query Builder returns the facets based on the type (cq:page, dam:Asset) for the above query, but I need the facets based on the tags. Is there any way, I can explicitly provide the parameter on which the facets are required. Also, please suggest if we can optimize this query to achieve the same.
Thanks,
Shailesh
This issue is fixed now. The mistake was in the tagid.property predicate. It should not start with #.
1_group.p.or=true
1_group.1_type=cq:Page
1_group.2_type=dam:Asset
2_group.p.or=true
2_group.1_path=/content
2_group.2_path=/content/dam
3_group.p.or=true
3_group.1_tagid=/etc/tags/geometrixx-outdoors/activity/biking
3_group.1_tagid.property=jcr:content/cq:tags
3_group.2_tagid=/etc/tags/geometrixx-outdoors/activity/biking
3_group.2_tagid.property=jcr:content/metadata/cq:tags
fulltext=text
p.limit=-1

Search on multiple keywords with tweetsharp

I am trying to use Tweetsharp to do a search on twitter for specific keywords but I want to do a search on multiple keywords. The following code works but only for one keyword. Anyone would know how to do an "or" search with tweetsharp?
ITwitterLeafNode searchQuery = FluentTwitter.CreateRequest()
.Search().Query()
.ContainingHashTag("heart")
.Since(sinceID)
.InLanguage("EN")
.Take(tweetCount)
.AsJson();
var results = searchQuery.Request().AsSearchResult();
Twitter's standard search operators seem to work fine with TweetSharp, so you could use the Containing() method instead:
var qry = FluentTwitter.CreateRequest()
.Search().Query()
.Containing("#heart OR #soul");
Note that the "OR" needs to be in capitals.
Whoops. Looks like we forgot to implement OR. Most people use "Containing" as a rote query expression like Matt has demonstrated. If you want us to add more extensions for boolean operators, let us know by filing a bug.

Resources