meteorhacks/search-source

Nested fields

Closed this issue · 6 comments

I am trying to use this package to search in nested fields of a document but it seems to cause a problem with the transform function on the client. (maybe by accessing the document fields like

 doc[field]

is causing the issue ?)

I am not really a js guy so I might be completely out.

Wich notation should we use to define the search in nested fields ?

Currently we don't support nested level fields.
But what's the error you are getting?

I am getting this:

Exception in template helper: TypeError: undefined is not a function

for this code

return UsersSearch.getData({
  transform: function(matchText, regExp) {
    return matchText.replace(regExp, "<b>$&</b>")
  },
  sort: {isoScore: -1}
});

At the return matchText.replace line

Okay. I know the issue.
I'll make a fix.

BTW: How do you define fields?
As a fix. Try to send fields without nested fields from the server

On Mon Jan 12 2015 at 4:29:20 PM Gus notifications@github.com wrote:

I am getting this:

Exception in template helper: TypeError: undefined is not a function

for this code

return UsersSearch.getData({
transform: function(matchText, regExp) {
return matchText.replace(regExp, "$&")
},
sort: {isoScore: -1}
});

At the return matchText.replace line


Reply to this email directly or view it on GitHub
#4 (comment)
.

In fact, I was doing things in a wrong way... Sorry to have disturbed.
My mistake was to define the emails field and not the emails.address like it should be.

The package is fine, I can search users on any field I want (nested or not)

I define my fields like this:

UsersSearch = new SearchSource('users',
['emails.address', 'profile.firstName', 'profile.lastName'],
options);

Thank you for this package, it is the best meteor search solution I saw so far (fast and easy to implement).

Hi! I'm having this problem, can you tell me how you solved it @elGusto ?
I have a field called profile.fullName and it does not works with the transformation function...
I'm using ES backend

SearchSources.userSearch = new SearchSource('userSearch',
  ['profile.fullName', 'username'],
  SEARCH_OPTIONS);

ps: username works just fine

@rafaelcorreiapoli I don't recall, but judging from the thread, it was an error from me. Like I was using 'emails.address' instead of 'emails.$.adress' or something similar.
Sorry I cannot be of more help...