Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOSL parsing error 2 #55

Open
xixiaofinland opened this issue Dec 11, 2024 · 3 comments
Open

SOSL parsing error 2 #55

xixiaofinland opened this issue Dec 11, 2024 · 3 comments

Comments

@xixiaofinland
Copy link
Contributor

class SOSLClass {
  void check() {
    searchResult = [
      FIND 'Hello'
      IN ALL FIELDS
      RETURNING Account(Id, Name USING ListView(id = listViewId))
    ];
  }
}
@xixiaofinland
Copy link
Contributor Author

Same goes to this.

class SOSLClass {
    void simpleSOSL() {
    String a = 'Hello';
    List<List<SObject>> searchResult = [FIND 'FirstLastName'];
    searchResult = [FIND :a];
    searchResult = [FIND :a USING PHRASE SEARCH];
    searchResult = [FIND :a USING ADVANCED SEARCH];
  }
}

@aheber
Copy link
Owner

aheber commented Dec 11, 2024

I don't think this is valid SOSL, built as a raw SOSL query instead of nested in Apex, shouldn't make a significant difference for the clause as far as I can tell, just easier to review in isolation.

FIND {Hello}
      IN ALL FIELDS
      RETURNING Account(Id, Name USING ListView(id = listViewId))

If I run it or things similar to it in an org then it fails to execute. Depending on which variation I run I get different errors.

FIND {Hello}
      IN ALL FIELDS
      RETURNING Account(Id, Name USING ListView(Id = Recent))

Produces
Invalid using expr

Using an Id (inside or outside of quotes)

FIND {Hello}
      IN ALL FIELDS
      RETURNING Account(Id, Name USING ListView(Id = '00BRL000008aC1W2AU'))

Produces

Account(Id, Name USING ListView(Id = '00BRL000008aC1W2AU'))
                                    ^
ERROR at Row:3:Column:53
Malformed search

This is probably on the fringe of "parsable but not executable" so I need to decide if I want to add support to parse it even though as far as I can tell it would never be valid in Apex or run in the org.

I'll have to think about it but I lean toward not going out of my way to add support, unless you can get me an example that does execute against an org.

@aheber
Copy link
Owner

aheber commented Dec 11, 2024

class SOSLClass {
void simpleSOSL() {
String a = 'Hello';
List<List> searchResult = [FIND 'FirstLastName'];
searchResult = [FIND :a];
searchResult = [FIND :a USING PHRASE SEARCH];
searchResult = [FIND :a USING ADVANCED SEARCH];
}
}

I'm going to move this to another issue. I think these are separate and as far as I can tell they are valid but not documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants