Search function does not find any results for words in the middle of name field.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • computerhighway
    Member
    • Jan 2016
    • 49

    Search function does not find any results for words in the middle of name field.

    The search box at the top of every layout does not find any result if the search word is not the first word of the name.
  • yuri
    Member
    • Mar 2014
    • 8510

    #2
    Try to use wildcard:

    "%York" will find "New York"
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • computerhighway
      Member
      • Jan 2016
      • 49

      #3
      Thank you, this is useful to know.

      Comment

      • hommelsheim
        Junior Member
        • Aug 2016
        • 10

        #4
        Thats not a useful solution. For a developer is a % as search pattern normally, but for the standard user not.
        How can i set the search pattern %pattern% as default search?

        Comment

        • tarasm
          Super Moderator
          • Mar 2014
          • 573

          #5
          I'm not sure that it's possible. It's a search standard for CRMs. Just teach your employees.
          Job Offers and Requests

          Comment

          • Clintre
            Junior Member
            • Sep 2016
            • 29

            #6
            Originally posted by tarasm
            I'm not sure that it's possible. It's a search standard for CRMs. Just teach your employees.
            I've never had that as a standard in CRM and we looked at a ton of them. Having it default to being %query% is very common and used in many web apps now days. I have not looked under the hood, but wrapping a query team in wildcards %queryterm% should not be very difficult.

            Comment

            • Clintre
              Junior Member
              • Sep 2016
              • 29

              #7
              Just to add to my post about you can add it to global search, fairly easily, by doing the following...

              Open file application/Espo/Controllers/GlobalSearch.php

              find
              PHP Code:
              $query = $request->get('q'); 
              
              add content below below
              PHP Code:
              $query = trim($query, '%');
              $query = '%'. $query .'%'; 
              
              I do the initial trim in case someone has already added the wildcard to the beginning or end, since this makes it a global wildcard.

              Now I have not looked at, nor do I know where the searches for individual plugins/pages are. However assuming it works in a similar fashion to the global search you could do the same thing. Took me about 5 minutes to find and add this and I did not have enough time to look for where the rest of the search calls were.


              Comment

              • Clintre
                Junior Member
                • Sep 2016
                • 29

                #8
                Ok, after a little more time to research it looks like in addition to the above change that does a true wildcard search on Global Search, you can also do it on the record list as well by making the very simple change below...

                Open file application/Espo/Core/SelectManagers/Base.php

                Go to line 1248 and change...

                PHP Code:
                $expression = $textFilter . '%'; 
                
                to

                PHP Code:
                $expression = '%'. $textFilter . '%'; 
                
                Now please keep in mind I do not know the application well enough to know if this will cause any other problems. In my quick, but VERY limited testing it worked pretty well.
                Last edited by Clintre; 10-18-2016, 01:22 PM.

                Comment

                • tanya
                  Senior Member
                  • Jun 2014
                  • 4308

                  #9
                  Don't forget that you can lose your modification after the upgrade... Try to put everything to the folder Custom
                  Last edited by tanya; 10-18-2016, 07:48 AM.

                  Comment

                  • Clintre
                    Junior Member
                    • Sep 2016
                    • 29

                    #10
                    Originally posted by tanya
                    Don't forget that you can lose your modification after the upgrade... Try to put everything to the folder Custom
                    Good point. Thanks

                    Comment

                    • peterberlin
                      Active Community Member
                      • Mar 2015
                      • 1004

                      #11
                      Why this solution is not integrated in the standard.? This saves typing%.
                      peter

                      Comment

                      • Clintre
                        Junior Member
                        • Sep 2016
                        • 29

                        #12
                        Originally posted by peterberlin
                        Why this solution is not integrated in the standard.? This saves typing%.
                        peter
                        I don't know, it would make sense and is how most systems work now days. Such a simple fix.

                        Comment

                        • alasdaircr
                          Active Community Member
                          • Aug 2014
                          • 525

                          #13
                          It's because text searching is slow, so if you have 10,000's of records it can slow down the queries.

                          I patch the % in to all text queries as my users have no concept of search modifiers and just expect everything to work like google.

                          It could be a configurable option in the Admin section ?

                          Comment

                          • bandtank
                            Active Community Member
                            • Mar 2017
                            • 379

                            #14
                            Originally posted by alasdaircr
                            It's because text searching is slow, so if you have 10,000's of records it can slow down the queries.

                            I patch the % in to all text queries as my users have no concept of search modifiers and just expect everything to work like google.

                            It could be a configurable option in the Admin section ?
                            Partial string searches are only slow when a real cache layer is absent. I added a Redis cache to my EspoCRM installation by modifying the most common searches to look in the cache first.

                            How would one add the %query% search to the custom folder? I don't understand the file structure yet, so I'm not sure where to put it or how to do it.

                            Comment

                            • alasdaircr
                              Active Community Member
                              • Aug 2014
                              • 525

                              #15
                              It was a patch to core, it's not possible in the custom folder. However I'm not using this anymore, I just use the config.php flag mentioned in the other thread you replied to.

                              Comment

                              Working...