I have a two-step search problem. First I want to see if any matches with the exact search-phrase - and then in step 2 take the generic full-text search across a number of properties.
I have mapped the property as follows:
[Field(Name = "CompanyNameFull",Index = Index.UnTokenized)]
[Field]
public string CompanyName { get; private set; }
My problem is that my users usually search in lowercase - and the company name is usually in proper case. So, "ibm*" doesn't find "IBM International", but "IBM*" does - and "ital*" doesn't find "Italian Furniture" while "Ital*" does.
I've tried in vain to attach an analyzer in the attribute to force it to be lowercase when indexed - but this fails, as the analyzer is only attached if it is a tokenized property (as far as I can tell). I've tried various querying alternatives to no avail either.
What am I missing?
I've found a solution using a custom tokenizer/analzyer. It isn't exactly ideal, but it should still work.
Related
Sorry in advance if this turns out to be such a simple question. I'm just starting out with GraphQL. I went here to learn about it:
https://graphql.org/learn/queries/
It's cool because the examples are in interactive editors. Under the Arguments subheading, for example, you can add id to the query, and then the output will contain "id": "1000". What's throwing me, though, is that in the subsequent sections (e.g., Aliases) there's an argument episode that's used. But when I try and add episode to the query, it doesn't work, and it isn't in the "auto complete" list of attributes of a hero. It seems strange that you could use an argument to filter on something but not use that field in the query. See screenshot.
I totally understand this is a simple page showing trivial examples for the purpose of learning. Is it perhaps that there's just a bug in this documentation? Or is episode there and I'm just not understanding something?
Thanks!
-Brian
The query for hero is just a function that does something. Its arguments are completely made up by whoever wrote the query, and are not related to the properties of the object it returns. For example, if you have some e-commerce website, you could allow a search for all customers who have purchased a specific product like:
type Query {
customersFromProductPurchased(productId: String!): [Customer]
}
and that doesn't mean that the Customer object is going to have a property called productId.
FWIW, the hero query returns a Character type. From just the autocomplete on that page, I can tell you that the type definition for Character looks like this:
type Character {
id: ID!
name: String!
friends: [Character]
friendsConnection: FriendsConnection!
appearsIn: [Episode]!
}
I'm trying to enable search for a custom entity, I've implemented the indexer and trying to execute search as below but the search doesn't return any document/results
SearchContext searchContext = SearchContextFactory.getInstance(request);
searchContext.setKeywords(keywords);
searchContext.setAttribute("paginationType", "more");
searchContext.setStart(0);
searchContext.setEnd(10);
Indexer indexer = IndexerRegistryUtil.getIndexer(Position.class);
Hits hits = indexer.search(searchContext);
System.out.println("Hit count: " + hits.getLength());
The indexer implementation seems to be working, as I can see the records indexed as expected using built-in elastic search console
localhost:9200/liferay-20116/_search
Any clue what can be the possible problem??
Just for additional info, my custom entity doesn't contain a field for 'groupId'
Look like for some reason you must have groupId in your entity in order for the search to work unless you are willing to dig and override the behavior
I added groupId to my entity (though I was not interested) and boom, it worked
I'm trying to get a list of Terms from a termvectorresponse in an elasticsearch plugin. I want to get access to all of the statistics which are tied to the terms and am having trouble figuring out how to do that.
After making a TermVectorsRequest...
TermVectorsRequest tvReq = new TermVectorsRequest(request.param("index"), request.param("type"), request.param("id"));
tvReq.termStatistics(true);
tvReq.selectedFields(request.param("field"));
and getting a response from the client...
TermVectorsResponse tvResponse = client.termVectors(tvReq).get();
I can get access to the id, index, etc. In the fields I get "contents" which is the field name that I want. From there though it looks like I can run...
tvResponse.getFields().terms("some term here")
in which the Terms object this returns has access to the stats I want.
I have a few issues with this though. One is that only "contents" seems to be non null. In the termvectors endpoint in elastic I get several different terms of which I've tried plugging into here. Two, is I want to get a list of terms rather than having to type in which term I want.
How can I go about doing this?
Thanks
Figured it out. Theres an interator on terms you can use. on .terms you have to pass it the field and you'll get the Terms object back. From that you can use the .iterator to get each individual term and do whatever you want with them.
I am talking about the functionality of the API that can be tested here: https://developers.google.com/+/web/api/rest/latest/people/search
I used to think it looks into all the public fields of a profile ("Specify a query string for full text search of public text in all profiles."), but it seems you can't search by email, telephone or some of the education and work information (even if the expected resulting profiles make this information public).
So my question is, what public data does this search use to retrieve its results? I can't find any documentation on this.
People: search
query string Specify a query string for full text search of public text in all profiles.
I found a random user. here I picked this guy because he had a lot of text in his profile.
Lets search on "gdesignart" This is part of his display name.
{
"kind": "plus#person",
"etag": "\"Sh4n9u6EtD24TM0RmWv7jTXojqc/W9DoYLbchkxsXWI_HhuWV6G7lJY\"",
"objectType": "person",
"id": "116044052555068441384",
"displayName": "Marcello Ghirardi (gdesignart)",
"url": "https://plus.google.com/116044052555068441384",
"image": {
"url": "https://lh3.googleusercontent.com/-IqYeJSv07cI/AAAAAAAAAAI/AAAAAAAAAPM/yw8nbO0Ho6g/photo.jpg?sz=50"
}
Works fine and I get a response.
Now lets try some text from his tagline or introduction arguably we could say this qualifies as public text on his profile.
I tried the following
G-Design®
è un brand
Pollutre of different world
None worked. If you look at the response the only thing in the response is the users display name. From my experience with other google APIs I can tell you that I don't think its going to let you search on any field that is not part of its response. So you are only going to be searching on DisplayName. For the fun of it I searched on his ID that didn't return anything either.
Answer: search is on display name only.
I would recommend adding this as a feature request if you link it here I will happily add my name to it. Google plus issue forum
I am executing a raven query in C#, and utilising both the Where() and Search() extension methods.
I need both these functionalities, because I need to only return indices with a specific Guid field, AND text that exists in a body of text.
Unfortunatly, the Where extension method seems to not be compatible with the Search extension method. When I combine them I get a Lucene query like this:
Query: FeedOwner:25eb541c\-b04a\-4f08\-b468\-65714f259ac2 MessageBody:<<request*>>
Which seems to completely ignore the 'MessageBody' part of the criteria - so it doesnt matter what constraint I use in the 'free text', it doesnt use it.
I have tested with the 'Search' alone, and it works - so its not a problem with free-text searching by itself - just combining the two.
Thanks to #Tobias on Raven#GoogleGroups who pointed me in the right direction - there was an option to define how the Where and Search clauses would be combined:
Query<T>.Search(candidate => candidate.MessageBody, queryString + "*", options: SearchOptions.And);