We need to write a SOSL Query - salesforce

We need to search for labor or warranties text from templates object.
I tried this SOSL Query
FIND {labor OR warranties} IN ALL FIELDS RETURNING Apttus__APTS_Template__c(Id,Name,Apttus__Mergefields__c)
but I am getting only few things like from few fields and apart from that we have that text(labor or warranties ) in content documents also but we are not getting that.
Can you please help me in querying the text from the template object so that it would return from the content documents also.

What do you get back with FIND {labor} IN ALL FIELDS RETURNING ContentVersion(Id, Title, ContentDocumentId). If it does return something promising you'd need to link it to your records (ContentDocumentLink table), perhaps few more queries to match it all up.

Related

SOLR: Search for a value in multiple fields

I am looking for a way of querying for values in multiple fields. Basically i am building a simple search engine where user can type ie. "Java How to XML JSON" and it will search for these values in 3 different fields categories, tags, description.
I read on some blog I should query all fields q=*:* and then filter based on those fields for example fq=categories:java,xml,how,to,json description:java,xml,how,to,json tags:java,xml,how,to,json
This works :| But it seems incorrect to just copy paste values like this.
Is there a correct way of doing this? I have been researching this for some time but i havent found a solution.
Any help is appreciated,
Thank you
You can use defType=edismax to get the extended dismax handler. This is meant to handle user typed queries (i.e. what you'd type in). You can then use qf (query fields) to tell the edismax handler which fields you want to search (and an optional weight for each field):
q=Java How to XML JSON&defType=edismax&qf=categories^5 tags description
.. will search each part of the string "Java How to XML JSON" in all the fields, and any hits in the categories field will be weighted five times higher than hits in the other two fields.

ArangoDB getting all unique tags from results

I've a document in ArangoDB.
{ title: "title 12345", tags : ["tagx", "tagy", "tagz"}
I've an full text index on title and another hash index on tags[*].
I've a query where I want to use full text search on title and apply some filtering via tags and get skip x limit 10 in results. I'm able to achieve this. This will help me in pagination. In one API call, I can return the user 10 items.
However, I also want to get all the unique tags which are present in the result(without skip and limit constraint) without hitting all the documents present in the result. This will help me to show the tags which user can further select to narrow down the search.
We can assume that there will be a small number of unique tags(around 30-40) in the database. Is there an efficient way to achieve this in ArangoDB? Maybe, we can create some new indexes or change the schema to achieve this.
Assuming that you are going to create a collection with documents named test with the following content
Just to be reproducible, the data that I am inserting is:
[{"_key":"342","_id":"test/342","_rev":"504","tags":["tagx","tagy","tagz"],"title":"title 12345"},{"_key":"564","_id":"test/564","_rev":"591","tags":["tagx","tagy","tagt"],"title":"title another"},{"_key":"510","_id":"test/510","_rev":"538","tags":["tagh","tagk","tagz"],"title":"title 56789"}]
If you run the following AQL query
let tags = (for i in test
return i.tags)[**]
return unique(tags)
This will return
[
[
"tagk",
"tagh",
"tagt",
"tagz",
"tagy",
"tagx"
]
]
As you can see there are different tags repeated across multiple documents and the results are showing an array with just the unique ones

Best way to query documents with a list of tags

I have an index which has a field that is a string collection, which contains a list of tags.
Does anyone know the most efficient way to query the index, with a list of tags to match against the tags string collection?
This is a very inefficient example of what I am trying to do:
/indexes/instruments/docs?api-version=2014-07-31-Preview&$top=10&$skip=0&$count=true&search=*&$filter=universes/any(t: t eq 'U') or universes/any(t: t eq 'B') or universes/any(t: t eq 'E')
In this example the tags field is "universes". The problem is that I need to filter on as many as 30 tags, so this query seems terrible!
This is the right way to express this query. It does look long syntactically but it should run fine from the efficiency perspective. What will dominate response time is not so much the number of terms here (at least in the order of magnitude you mentioned) but how big the matching set is.
10/16/2017 update: note that Azure Search now has a new filter function, search.in(), that provides a more compact representation and faster execution for queries like this. More details and API version requirements here: https://learn.microsoft.com/en-us/rest/api/searchservice/odata-expression-syntax-for-azure-search
Because you want to implement an explicit filter your query is indeed probably the best you can do. This style of filter will handle the tags being in any order which makes it better than other solutions that include 'fixing' the index by injecting fields that are a concatenated result of multiple tags.
For 30+ tags you might also get good results using a tag 'boost' scoring profile, then you can pass in the tags that you want as a parameter, give the results an unreasonably high boost. If then need to specifically filter by tags then in this scenario you would have to filter on the client to remove results that did not receive a score from your boost profile
http://azure.microsoft.com/blog/2015/02/05/personalizing-search-results-announcing-tag-boosting-in-azure-search/

Solr Suggester: Return multiple fields in response

I am using Solr version 3.5. I want to implement an auto-suggest feature in my application through the Suggester approach. http://wiki.apache.org/solr/Suggester.
Can someone please help me with the following:
How can i return more than one fields in the query response. For example, i am trying to create an index based on the 'name' field, but i also want to return an 'id' field where these two fields are the product attributes i am search for [say movie titles]. Hence, the response should include both the 'id' and 'title' of the product
How can i do a case-insensitive search using Suggester? For example, a search term "abc" should return documents containing the name as "ABC", "Abc" etc.
Please help.
Regards.
If you're looking to get suggestions on a particular field but also return other fields in the document, you can use the 'Payload' tag. Only one payload field is allowed, but you can get around this by using a json format in the field.
https://cwiki.apache.org/confluence/display/solr/Suggester
https://stackoverflow.com/a/32558487/578582
I think you're not quite getting the point of the suggester. It is not designed to return suggestions for exactly one search result per entry (this is the only scenario where returning the ID would make sense).
You could, however, do normal wildcard searches on the title field and use the returned titles as suggestions. This way you could also get the ID (and any other index field) with the results. I imagine this could be implemented fairly easily with jQuery UI. It may be much slower than the suggest API, depending on your index schema design.
if you are not really interested in the order of the suggestions i found that the weight_field can be [ab]used to return the document id for each suggestion

Solr: Query and return x number of types

I have a large index of files. One of the fields I have is "content_type". This field stores the basic type for a file (i.e. pdf, image, video, document, spreadsheet, etc).
I'm running a search on files names (my "title" field). How can I structure the query so that it returns only a certain amount of each type?
For example, say I have 1000 files with the word "work" in the title. I want to search for "work" in the title, but I want 5 results from each "content_type" returned first. (assuming that each specific content_type has 5 or more items). So on my search results page I can say:
1,000 items were found for "work"
Then I start listing listing the items, 5 for each type.
Can anyone help me build a query that will do this? I'm pretty new to Solr, but I'm hoping this can be done.
Seems basically you want to limit and group the results per content type.
Check out the Solr field Collapsing and grouping feature
This will help you to group the results per content type using group.field=content_type
The number of results in a group can be limited by group.limit=5
For the complete list of options refer to the link above.
And you can use the normal query parameters to search the results i.e. q=work
This feature is only available from the Solr 3.3 build.

Resources