ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Exact match results issue

September 12, 2010 4:24pm

Subscribe [4]
  • #1 / Sep 12, 2010 4:24pm

    Dragan Simonovic

    71 posts

    Hello,

    Trying to figure out exact_match search but without any luck.

    I have a simple search form with only a single keywords field and where=“exact” parameter.

    Now, when I search for B92 9BA there is only a single result which is correct because there is only a single entry with that title.

    But when I search for B92 9B there are plenty of results like B92 9BB, B92 9BC, etc… but in this case I need to return no_results page.

    I tried to do the same in Admin panel and when I search for B92 9B and check Exact Match field EE returns no results message There are no entries matching the criteria you selected which is exactly what I need.

    How to achieve this with simple search form?

  • #2 / Sep 12, 2010 7:24pm

    Brandon Jones

    5500 posts

    Hi Vibrant Drive,

    Can I confirm the version and build of EE you’re using? Have you tried where=“word” as well?

  • #3 / Sep 13, 2010 2:57am

    Dragan Simonovic

    71 posts

    Hi Brandon,

    EE version is 1.6.9.

    I tried where=“word” but since I’m searching UK postcodes (ex. B92 9BB) EE treat this example as two separate words and because of that search results are not accurate.

    When I use where=“exact” and search for B92 9BB EE back only a single result and that’s what I need. But when I search for ex. B92 9B then I get results like B92 9BA, B92 9BD and so on (notice last character).

    So how to force simple/advanced search to treat B92 9B as a single word, like B92 9BB, and display search result only if B92 9B exist in a database but not to search for B92 9B keyword as containing word of for example B92 9BC postcode?

  • #4 / Sep 13, 2010 3:06am

    Dragan Simonovic

    71 posts

    This is my simple search form code:

    {exp:search:simple_form weblog="postcodes" search_in="titles" where="exact" result_page="site/results" no_result_page="site/noresults"}
                        <input type="text" name="keywords" id="keywords" value="" maxlength="15" />
                        
                        <button type="submit">Go</button>
                    {/exp:search:simple_form}


    When I search for B92 9BA, this is the whole postcode number, I get only a single result B92 9BA because there is only a single postcode that meet search keyword.

    But when I search for B92 9B, which is partial postcode, I get the following results:

    B92 9BB, B92 9BD, B92 9BE, B92 9BG, B92 9BH, B92 9BJ, B92 9BL, B92 9BN, B92 9BP, B92 9BQ, B92 9BS, B92 9BT, B92 9BU, B92 9BW, B92 9BA

    So the problem here is that I need B92 9B to be treated as a whole postcode number and not as a containing word of other postcode numbers.

    This works fine when I use Admin panel filter in Edit section and check Exact Matching field. For B92 9BA I get only a single result which is correct and when I search for B92 9B EE treat this as a whole word and display no results message because there is no postcode like this one.

    So I need the same functionality for simple/advanced search form on front-end.

  • #5 / Sep 13, 2010 9:10am

    Sue Crocker

    26054 posts

    What happens if you put the B92 9B in double quotes?

  • #6 / Sep 13, 2010 9:17am

    Dragan Simonovic

    71 posts

    Hi Sue,

    I’ve changed with parameter to with=“word” and now when enter “B92 9B” (with quotes) I get no results page which is exactly what I need.

    My question is how to force simple search form to always use quotes for keyword?

    Thanks in advance.

  • #7 / Sep 13, 2010 2:22pm

    Dragan Simonovic

    71 posts

    Anyone?

  • #8 / Sep 14, 2010 3:31am

    John Henry Donovan

    12339 posts

    Vibrant Drive,

    You will probably need to achieve this with some JavasScript. I can move this thread to the CodeShare Corner if you wish to open it up to the community?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases